简体   繁体   English

在 Android 10 及更高版本的应用程序设置中创建多选列表的最佳方法是什么?

[英]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.我正在基于预定义的 RSS 源列表开发一个简单的新闻应用程序。 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.我正在考虑设置菜单中的 ListPreference,它包含可用的源,但具有多项选择的性质,而不是默认的单项选择。 (as the official Material Design guide suggests for multi-choice setting entries). (正如官方材料设计指南建议的多选设置条目)。

I found that MultiSelectListPreference exists, and is exactly what I need.我发现MultiSelectListPreference存在,这正是我所需要的。 However this class is deprecated since API level 29. Sadly, the official page does not give enogh information about what should be used now.然而,这个类自 API 级别 29 起已被弃用。遗憾的是,官方页面没有提供关于现在应该使用什么的信息。

What is the recommended way to create a similar functionality as MultiSelectListPreference in API level 29 and higher?在 API 级别 29 及更高级别中创建与 MultiSelectListPreference 类似的功能的推荐方法是什么?

The replacement is MultiSelectListPreference from the AndroidX preference library .替代品AndroidX 首选项库中的MultiSelectListPreference See this guide for how to use that library.有关如何使用该库的信息,请参阅本指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM