简体   繁体   English

如何在自定义适配器列表视图中同时获取行选择事件和项目单击事件

[英]How to get row selection event and item click event in custom adapter listview all together in Android

I have custom list of two text views having different text string. 我有两个具有不同文本字符串的文本视图的自定义列表。 These are items in the list. 这些是列表中的项目。 In current scenerio I can only register the setOnItemClickListener for the list. 在当前场景中,我只能为列表注册setOnItemClickListener。 This is triggered when the item in the list is clicked. 单击列表中的项目时将触发此事件。 If I click on the other portion of the row, no event is generated.. 如果单击行的另一部分,则不会生成任何事件。

How can I have the item click as well as the row click event all together, so that wherever I click on the row of the list an event is triggered. 如何将项目单击和行单击事件放在一起,以便无论我在列表行上单击什么位置,都会触发一个事件。

You can achieve this by implementing callback Interface. 您可以通过实现回调接口来实现。

Implement onClickListener for a particular view and use callback listener to get the callback to you fragment or activity. 为特定视图实现onClickListener并使用回调侦听器将回调传递给您的片段或活动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM