Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ListView with Checkbox and all clickable [duplicate]

Possible Duplicate:
Android: Binding data from a database to a CheckBox in a ListView?

i want to use a ListView with the items having following layout

-------------------------   [CB]    TV            TV ------------------------- 

CB is a checkbox and TV is a Textview.

Now i've read somewhere that you can't have clickable items in a ListView. If you have some then you won't be able to click on the ListItems. But if I look at the GoogleMail app, this is possible. I can mark several messages with the checkbox (and then select an action for them) or i can click on the ListItem (or scroll with the dpad) to get to another screen. Does someone has code/example how this is possible?

like image 798
codie4711 Avatar asked Mar 24 '11 09:03

codie4711


1 Answers

Set the CheckBox as focusable="false" in your XML layout. Otherwise it will steal click events from the list view.

Of course, if you do this, you need to manually handle marking the CheckBox as checked/unchecked if the list item is clicked instead of the CheckBox, but you probably want that anyway.

like image 57
PacificSky Avatar answered Sep 28 '22 03:09

PacificSky