How to get selected list items from a Listview with checkBox and Custom Adapter?

前端 未结 4 441
攒了一身酷
攒了一身酷 2020-12-02 21:14

I have a ListView with CheckBox on it. and i am using Custom Adapter to populate the ListView.

In my xml

4条回答
  •  天涯浪人
    2020-12-02 22:20

    In the customadapter's getview method, do

    //use the actual id of your checkbox of course
    Checkbox checkbox = (CheckBox)findViewById(R.id.checkbox); 
    checkbox.setFocusable(false);
    checkbox.setFocusableInTouchMode(false);
    

    now the checkbox is clickable as is the listitem.

提交回复
热议问题