2

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

Community
  • 1
  • 1
Name is Nilay
  • 2,743
  • 4
  • 35
  • 77

2 Answers2

2

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"
jeet
  • 29,001
  • 6
  • 52
  • 53
  • But i have a small question...what if i store the clicks on Checkboxes and store it in List and then convert the list into single String..??? – Name is Nilay Jun 28 '12 at 05:58
  • you can have a boolean array equal to the size of listitems, and can toggle each item on item click method callback. – jeet Jun 28 '12 at 06:10
0

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"
Yogesh Somani
  • 2,624
  • 3
  • 21
  • 34