Change Themes
Back inside preferences.xml, let’s add a new <DropDownPreference> to the Theme Settings category. In addition to the normal attributes we’ve set previously, we have three more we’re using here.
Add Additional Preference Attributes
app:useSimpleSummaryProvider handles updating the summary text whenever we change the value of our preference, which we can use both here and once we get to the night mode support. The other two attributes are android:entries and android:entryValues, which give us a way to populate our drop-down list. Both of these values live inside res/values/arrays.xml (which you probably need to create). Before we add those values, here’s the full <DropDownPreference>:
| <DropDownPreference |
| android:defaultValue= ... |
Get Kotlin and Android Development featuring Jetpack now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.