ListView: setItemChecked only works with standard ArrayAdapter - does NOT work when using customized ArrayAdapter?

前端 未结 4 1834
遇见更好的自我
遇见更好的自我 2020-12-04 16:35

This is really weird.

When I use the standard ArrayAdapter for a ListView calling setItemChecked works OK

But when using a custom made ArrayAdapter it does n

4条回答
  •  清歌不尽
    2020-12-04 17:26

    Your row layout needs to be Checkable for setItemChecked() to work, in which case Android will manage calling setChecked() on your Checkable as the user clicks on the row. You would not need to be setting up your own OnCheckedChangeListener.

    For more, see:

    • ListView with CHOICE_MODE_MULTIPLE using CheckedText in a custom view
    • Multiple choice list with custom view?
    • http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/
    • http://tokudu.com/2010/android-checkable-linear-layout/
    • http://alvinalexander.com/java/jwarehouse/apps-for-android/RingsExtended/src/com/example/android/rings_extended/CheckableRelativeLayout.java.shtml

提交回复
热议问题