I've got a strange error. I'm comparing preference changes when the preference changes.
When a preference changes it gives me a string of the key that's changed.
I've made a list of IF statments to check which statement changes and to update that current preference (performance etc etc, and since we can't use sharedprefs onDestory we have to do one at a time..)
Anyhow the other keys are working but this one seems to fail at the end. Here:
First of all we have the XML: (PS this function changes the size of the bitmap within the app)
This is within the values.xml
<string-array name="itemSize">
<item>Small</item>
<item>Medium</item>
<item>Large</item>
</string-array>
<string-array name="itemSizeNumbers">
<item>8</item>
<item>12</item>
<item>18</item>
</string-array>
This is within the settings.xml
<ListPreference
android:title="Item Size"
android:summary="Set the Item size."
android:key="ItemSize"
android:defaultValue="Medium"
android:entries="@array/ItemSize"
android:entryValues="@array/ItemSizeNumbers"
/>
When the preference is changed this function is called:
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{
if(started)
{
_battlefield.upDateValues(key);
}
}
That passes onto: (Probably where the problem is)
public void upDateValues(String key)
{
//This returns ItemSize on item size change.
Log.w("myapp", key);
String nkey = key;
if(nkey == "Items")
{
//This one works
this._no_of_Items = this.prefs.getInt("Items", 4);
}
if(nkey == "respawn")
{
//This one works
this._respawn_time = this.prefs.getInt("respawn", 1);
}
//The fail zone.
if(nkey == "ItemSize")
{
//This one does not work! Key outputs ItemSize ????
Log.w("myapp", "Item size activated");
this._items_screen_percentage = this.prefs.getInt("ItemSize", 10);
this.initializeBitmaps();
//this.initialize(_context, _surfaceHolder, prefs);
}
}