Android : How to add bitmap on preference?

on Sunday, July 6, 2014


how can I add my imported images on my preference? I want to have a settings that the player can choose what his desired character?


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) {
}


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


0 comments:

Post a Comment