The settings list returns entries, not EntryValues

I created the List prefix in my Preferences setting and the value returned by the code for the selected item is the Entry value, not the EntryValues ​​value.

Example:
Record: David News Value: DAVIDNEW.TTF

Codes return "David New" instead of "DAVIDNEW.TTF".


Here is the code:

File preferences.xml:

<ListPreference
            android:key="fontSelect"
            android:title="@string/textPrefs"
            android:summary="@string/textPrefs"
            android:defaultValue="DAVIDNEW.TTF"
            android:entries="@array/fonts"
            android:entryValues="@array/fontsValues" />

File arrays.xml:

<string-array name="fonts">
    <item>Alex</item>
    <item>Cardo</item>
    <item>Chaya</item>
    <item>David New</item>
    <item>Droid Sans</item>
    <item>Frank</item>
    <item>Mike Hebrew</item>
</string-array>
<string-array name="fontsValues">
    <item>ALEX.TTF</item>
    <item>Cardo99s.ttf</item>
    <item>CHAYA.TTF</item>
    <item>DAVIDNEW.TTF</item>
    <item>DroidSansHebrew.ttf</item>
    <item>frank.ttf</item>
    <item>mike_hebrew_regular_v33.ttf</item>
</string-array>

File reader.java:

String f1 = new String(myprefs.getString("fontSelect", "DAVIDNEW.TTF"));
font = Typeface.createFromAsset(getAssets(), f1);
tv.setTypeface(font);

The value f1is "David New" instead of "DAVIDNEW.TTF".

+3
source share

All Articles