android中像这样的列表怎么获取其中每一行的点击事件呢,就是点击每一个选项就能转到其他Activity的方法

 我来答
心中风情4
推荐于2016-08-22 · TA获得超过2247个赞
知道大有可为答主
回答量:1779
采纳率:66%
帮助的人:1040万
展开全部
android中像这样的列表中有个函数onlistItemclick,其中有个参数是int position,根据position当然就能知道点了那个,该干什麽(比如跳到哪个activity)
追问
能具体告诉我该怎么写么,比如onlistitemclick的四个参数都代表什么意思呢?
追答
* @param l The ListView where the click happened 
* @param v The view that was clicked within the ListView
* @param position The position of the view in the list
* @param id The row id of the item that was clicked
*/
protected void onListItemClick(ListView l, View v, int position, long id) {
intent intent;
if(id == 1) {
intent = new Intent(this, "MondayActivity");
}
else(id ==2) {
intent = new Intent(this, "TuesdayActivity");
}
//....

if(intent != null) startActivity(intent);
}

类似这样,用id比较保险,position如果listview超出屏幕,估计就不对了
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式