1

I want to have a setting that the player can choose their desired character. How can I use my imported images as the items on my List Preference view?

This is the screenshot of XML:

enter image description here

<ListPreference
    android:key="bitmap"
    android:title="Character"
    android:entries="@array/bitmap"
    android:entryValues="@array/bitmap_resources"
    android:dialogTitle="Select Character" />

In my array:

<string-array name="bitmap">
    <item>Car</item>
    <item>Ghost</item>
    <item>Human</item>
</string-array>
<string-array name="bitmap_resources">
    <item>**???**</item>
    <item>**???**</item>
    <item>**???**</item>
</string-array>

In my class:

SharedPreferences prefs =
    PreferenceManager.getDefaultSharedPreferences(context);

Drawable bitmap_char =
    getResources().getDrawable(R.drawable.hero);

String bitmapStr = 
    prefs.getString("bitmap", "");

    if(bitmapStr.length() > 0) {
    }

What am I doing wrong? I can vote for any help or suggestions. thanks.

  • 1
    sorry i just want to update my question since i didn't get any response on other user. The question before was already been deleted. please apologize –  Jul 07 '14 at 03:58
  • @matiash Unable to open link. – App Kart Jul 07 '14 at 04:13
  • @AppKart it was a duplicate question posed _by this same user_. He already deleted it. Nevermind. – matiash Jul 07 '14 at 04:16
  • 1
    http://stackoverflow.com/questions/8586242/how-can-i-store-images-using-sharedpreference-in-android – App Kart Jul 07 '14 at 04:22
  • sir @AppKart the codes on the link is much harder to read because it is already using the gallery. My only objective here is that I will import selected character images through drawable folders and store them in a preference then a settings that will allow the player to pick its desired character –  Jul 07 '14 at 06:06

0 Answers0