Maximum Number of Choices MultiSelectListPreference Android

Is there a way to set the maximum number of selections for MultiSelectListPreference in Android? I want the user to be able to select a maximum of 5 values. Here is my xml:

<MultiSelectListPreference
        android:key="user_interests"
        android:title="interests"
        android:entries="@array/interests_array"
        android:entryValues="@array/interests_values"
        android:defaultValue="@array/interests_default_values" />

If it would be easier to get more complex functionality from a single fragment, I would be happy to use this; although I'm not sure how to run the snippet from xml PreferenceScreen; I tried Android: Fragment, but to no avail.

+4
source share

Source: https://habr.com/ru/post/1629098/


All Articles