Android save Checkbox State in ListView with Cursor Adapter

后端 未结 5 1949
忘掉有多难
忘掉有多难 2020-11-27 19:48

I cant find a way to save the checkbox state when using a Cursor adapter. Everything else works fine but if i click on a checkbox it is repeated when it is recycled. Ive see

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 20:25

    I would recommend you use Android's built-in support for multiple-choice lists (CHOICE_MODE_MULTIPLE).

    The List11.java SDK sample demonstrates this. You can also find a project from one of my tutorials that uses it here.

    You can still use this technique with your own layout, so long as you include a CheckedTextView with android:id="@android:id/text1" as shown in the android.R.layout.simple_list_item_multiple_choice resource, a copy of which ships with your SDK.

    Also, see this question and this question and this question and this question.

提交回复
热议问题