onListItemClick method not called when I use Check

2019-05-23 02:31发布

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...

2条回答
看我几分像从前
2楼-- · 2019-05-23 03:07

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"
查看更多
Luminary・发光体
3楼-- · 2019-05-23 03:31

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"
查看更多
登录 后发表回答