Actually the question, I bring all this to ListPreferences like this: prefs.xml

<ListPreference android:title="@string/Title" android:summary="@string/Summary" android:key="PreferenceKey" android:defaultValue="VALUE_2" android:entries="@array/Entries" android:entryValues="@array/Values" /> 

array.xml:

 <string-array name="Entries"> <item>@string/Value1</item> <item>@string/Value2</item> <item>@string/Value2</item> </string-array> <string-array name="Values"> <item>VALUE_1</item> <item>VALUE_2</item> <item>VALUE_3</item> </string-array> 

How do I set the selected example from Entries value1? I searched the Internet, found nothing and decided to contact you.

    3 answers 3

     <ListPreference android:title="@string/Title" android:summary="@string/Summary" android:key="PreferenceKey" android:defaultValue="VALUE_2" android:entries="@array/Entries" android:entryValues="@array/Values" android:defaultValue="value1" /> 
       <ListPreference android:title="@string/Title" android:summary="@string/Summary" android:key="PreferenceKey" android:entries="@array/Entries" android:entryValues="@array/Values" android:defaultValue="value1" /> 

      or

       setValueIndex(int index); 

      or

        CheckBoxPreference dualCoreModePref = (CheckBoxPreference) getPreferenceManager().findPreference("PreferenceKey"); dualCoreModePref.setChecked(getPreferenceManager().getSharedPreferences().getBoolean(dualCoreModePref.getKey(), 1)); 
      • Even it is not clear where to insert it) - dajver

      I think I need to create a Java file Prefs.java in it to "point" to prefs.xml and link it with Main.java with Prefs.java.