androidlistpreferencepreferencescreenandroid-multiselectlistpreference

What is the best way to create a multi-choice list in application settings on Android 10 and higher?


I'm working on a simple news app based on a predefined list of RSS sources. I want to give the users the choice, to choose which sources they want to use. I'm thinking about a ListPreference in the settings menu, containing the available sources, but with a multi-choice nature, rather than the default single choice. (as the official Material Design guide suggests for multi-choice setting entries).

I found that MultiSelectListPreference exists, and is exactly what I need. However this class is deprecated since API level 29. Sadly, the official page does not give enogh information about what should be used now.

What is the recommended way to create a similar functionality as MultiSelectListPreference in API level 29 and higher?


Solution

  • The replacement is MultiSelectListPreference from the AndroidX preference library. See this guide for how to use that library.