I have added a checkbox inside a list view, but i am able to select and unselect only the checkboxes but i cannot select the list item. How to overcome this problem? Any help is appreciated and thanks in advance…
My Code Goes Here
List<String> lst = dh.selectAll();
lv = (ListView)findViewById(R.id.listView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.list,R.id.textViewx,lst);
lv.setAdapter(adapter);
lv.setOnItemClickListener(this);
dh.selectall() -> Contains the listarray of items from database;
lv -> list view identified
I’ve used array adapter and identified a textview to enter items in listview
at last, I’ve given a clicklistener to the listview by implementing OnItemClickListener.
You should use multiple choice listview. Fits your needs perfectly. Here is a link to a good tutorial : http://mubasheralam.com/tutorials/android/how-create-multiple-choice-list
Update 1
When you have a checkable item in your listview, the touch on item will not be delivered to item. Just to test, set your checkbox as non clickable.
chkox.setClickable(false);and test. The clicks will be delivered to your item.Update 2
You should use
android.R.layout.simple_list_item_multiple_choicefor list item.