Android ListView with multiple select and custom adapter

前端 未结 3 561
悲哀的现实
悲哀的现实 2021-01-11 13:23

I have a ListView with a custom adapter. The ListView allows multiple select, but somehow it\'s not recognising when an item is selected.

I

相关标签:
3条回答
  • 2021-01-11 13:45

    Just have a try:

    1. listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

    2. holder.checkbox.setFocusable(false);

    3. I think that is the listView's sub item view shoudld implements the Checkable interface, that means the converted View(convertView) should have all the method of Checkable.

    0 讨论(0)
  • 2021-01-11 13:48

    I had a similar problem. My list item view is a RealativeLayout with a LinearLayout containing a CheckBox and a TextView. No onItem...Listener was called until I did set the CheckBox.focusable to false. Furthermore not the objects in the adapter should be Checkable but the views used as the layout for the list item.

    0 讨论(0)
  • 2021-01-11 13:58

    I had a problem like this once. It has something to do with the fact that you have a view on the adapter that is selectable causing the parent to ignore it. Removing it allows you to select the row of the listview again. What you've created is basically a button on a button, android does not like that :-(

    0 讨论(0)
提交回复
热议问题