如何在不扩展ListActivity的情况下处理ListView的onClick?
我有一个列表视图,填充如下并且它正在工作。我的问题是能够处理 onclick。我没有扩展列表活动,因为我的所有活动都扩展了一个通用活动,我用它来设置所有活动中使用的通用变量/首选项/等。有没有办法在不扩展 listactivity 的情况下处理 onclick ?如果没有,有没有办法导入列表活动(通过类或其他东西)?
ListView lv = (ListView)findViewById(R.id.listViewGhostCams);
SimpleAdapter adapter = new SimpleAdapter(
this,
list,
R.layout.custom_row_view,
new String[] {"pen","price","color"},
new int[] {R.id.text1,R.id.text2, R.id.text3}
);
populateList();
lv.setAdapter(adapter);
我是 android / java 编程新手,所以请温柔一点! :-)
谢谢, 香农
I have a listview populated as follows and it's working. My issue is with being able to handle the onclick. I'm not extending the listactivity because all my activities extend a common activity that I use to setup common variables/preferences/etc that are used on all activities. Is there a way to handle the onclick without extending the listactivity? and if not, is there a way to import the listactivity (via a class or something)?
ListView lv = (ListView)findViewById(R.id.listViewGhostCams);
SimpleAdapter adapter = new SimpleAdapter(
this,
list,
R.layout.custom_row_view,
new String[] {"pen","price","color"},
new int[] {R.id.text1,R.id.text2, R.id.text3}
);
populateList();
lv.setAdapter(adapter);
I'm new to android / java programming so please be gentle! :-)
Thanks,
Shannon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 OnItemClickListener 来执行此操作
You can do this with OnItemClickListener
我猜你的意思是 onClick on an item?只需使用这一点:
I guess you mean onClick on an item? Just use this bit:
您可以使用 onItemClickListener
you can user onItemClickListener