4

I am new to Android. I have a MultiSelectListPreference and I would be able to check/uncheck all the boxes, possibly through a "Select All" checkbox next to the category title, in short something like this:

enter image description here

This is my MultiSelectListPreference from my preference xml file:

<MultiSelectListPreference
    android:title="Items list"
    android:key="itemsList"
    android:entries="@array/list"
    android:entryValues="@array/listValues"
    android:defaultValue="@array/listValues">
</MultiSelectListPreference>

Here the arrays:

<string-array name = "list">
     <item>Item 1</item>
     <item>Item 2</item>
     <item>Item 3</item>
     <item>Item 4</item>
</string-array>

<string-array name = "listValues">
     <item>1</item>
     <item>2</item>
     <item>3</item>
     <item>4</item>
</string-array>

Is there any way to implement it?

4

1 回答 1

1

setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener)添加到标题中的复选框。在 onCheckedChanged 回调中检查 listadapter 中的所有项目并标记为选中

并检查这个答案

于 2015-11-23T22:49:24.900 回答