开发者

List Preferences is returning Entries and not EntryValues

I created a List Preference in my Preferences Activity and the value that the code is returning for the selected item is the value of the Entry and not the value of the EntryValues.

Example:

Entry: David New

Value: DAVIDNEW.TTF

The codes returns "David New" instead of "DAVIDNEW.TTF".


Here's 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-arra开发者_开发问答y 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);

Value of f1 is "David New" instead of "DAVIDNEW.TTF".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜