What is the difference between entries and entry values in android listPreferences xml?

johnrao07 picture johnrao07 · Oct 21, 2015 · Viewed 7.6k times · Source

Here is my code:

How do they differ and which values get displayed on the dialog?

<ListPreference
    android:entryValues="@array/level"
    android:entries="@array/level"
    android:key="pref_numberOfChoices"
    android:persistent="true"
    android:summary="@string/level_description"
    android:title="@string/level_title"
    android:defaultValue="3"/>

Answer

yugidroid picture yugidroid · Oct 21, 2015

You can check out the official doc about ListPreference.

android:entries The human-readable array to present as a list.

android:entryValues The array to find the value to save for a preference when an entry from entries is selected.

I other words: entries is what you see in the list and entryValues are the values you want to save when you do some action with the respective entry value.