在 ListView 中选择项目时出现问题?
我设计了一个应用程序。它列出了您正在使用的设备或模拟器上已安装的所有应用程序。请参阅此。这是我的模拟器结果。在该列表中,仅当我选择复选框时才可以检查该项目。但是,我无法通过按该项目来选择任何项目。我设计这个程序仅通过活动扩展。并且,我还使用适配器来列出它。如何通过按项目来选择项目。我怎样才能做到这一点?提前致谢。
I've designed one application. It lists all the installed application's on device or emulator which is you're using.See this. It's my result from emulator. In that List the that i can checked the item when i select checkbox only. But, i can't select any item by pressing that item. Am design this program extends by Activity only. And, also am using Adapter for listing that. How can i select the item by pressing item. How can i done this? Advance thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为您的列表视图包含一个复选框,所以 android 让用户与该视图交互,而不是“选择项目”。换句话说,单击是由包含复选框的视图而不是列表视图处理的。
您可以尝试处理视图中的触摸事件,然后调用父活动并要求其选择该项目。
Because your list view contains a checkbox, android is letting the user interact with that view rather than "selecting the item". In other words, the click is being handled by the view which contains the checkbox rather than the listview.
You could try handling the touch event in the view and then calling the parent activity and asking it to select the item.
将 OnClickMethod 设置为您选择的布局,然后更改所选布局的背景。
而不是你的列表视图
Set OnClickMethod to your selected layout then change background of selected layout.
instead your listview