onListItemClick method not called when I use Checkox in list

怎甘沉沦 提交于 2019-12-10 10:53:56

问题


Hi guys I am new to android...I want to display a dynamic list of CheckBox and on Clicking multiple of those CheckBoxes i want their data in a single string...But my problem is that i am unable to call onListItemClick method if I use checkBox in my List...

It is my understanding and experience however that putting a focusable view in the list item prevents the firing of onListItemClick() in the ListActivity when the list item is clicked. But can anyone Plz give me solution...

I have referred links like

How to fire onListItemClick in Listactivity with buttons in list?

Android ListActivity onListItemClick calls adapter getView

but unable to find a solution...


回答1:


To make it working you can set Checkboxes and other fields in the ListItem unclickable and unfocusable, by properties:

android:clickable="false"
android:focusable="false"



回答2:


Make sure you set the checkbox as not focusable in the adapter class, like this:

        yourCheckbox.setFocusable(false);

And in the xml file as well:

        android:focusable="false"


来源:https://stackoverflow.com/questions/11238639/onlistitemclick-method-not-called-when-i-use-checkox-in-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!