I know there’s tons of other threads around about this same topic, but none of them seem to work with my scenario and I couldn’t get my listview to work with their code. Basically, I’m using a SimpleCursorAdapter to populate a listview with items from the database. Each listview row uses a custom layout which consists of a checkbox and a line of simple text. How do I detect a click on the checkbox? I know I need to use OnItemClickListener, but I don’t know how to incorporate that into my code. Here’s my code:
remindersCursorAdapter = new SimpleCursorAdapter(this,
R.xml.view_reminders_item_layout,
remindersCursor, new String [] { RemindersDAO.NAME },
new int[] { R.id.view_reminders_item_text } );
viewRemindersListView.setAdapter(remindersCursorAdapter);
R.xml.view_reminders_item_layout is the custom listview layout file. How do I capture the checkbox from this file and set a click listener to it? Thanks for all your help!
If you want to check the checkbox when a item is clicked, you can do it by setting checked status of Checkbox in onItemClick method.
If you want to detect the click on only checkbox then set the focusable true in xml.
// in your custom list view item. It takes the current view focus.