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:
<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.