You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to load preferences in my app, I keep getting the error "java.lang.RuntimeException: Unable to start activity ComponentInfo{.......MyPreferencesActivity}: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)"
In my activityMain I default the sharedPreference for a key value (upon first launch of the app): SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putInt("go_circle_colour_pref_key",Integer.parseInt("0x00ff00"));
In my preferences.xml, I have: <com.rarepebble.colorpicker.ColorPreference android:key="go_circle_colour_pref_key" android:title="@string/goColour" app:colorpicker_showAlpha="true" />
I have tried:
putting default colours in the preferences.xml, e.g. <!--android:defaultValue="#f00"-->
If I give the color-picker preference in xml a key that doesn't actually get used (initialised in activityMain), then the colour picker works OK. I seem to be initialising the key incorrectly.
The text was updated successfully, but these errors were encountered:
This fixed things - thanks!
So the preference just had to be initialised with both alpha and rgb? I got the impression from the example code on the readme that just rgb was needed - but this was my mistake. I thought the value from "ColorPickerView usage" (....picker.setColor(0xff12345);...) would apply to initialising preferences.
edit: added PR which updates readme with SharedPreferences initialization at onCreate().
When I try to load preferences in my app, I keep getting the error "java.lang.RuntimeException: Unable to start activity ComponentInfo{.......MyPreferencesActivity}: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)"
In my activityMain I default the sharedPreference for a key value (upon first launch of the app):
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putInt("go_circle_colour_pref_key",Integer.parseInt("0x00ff00"));
In my preferences.xml, I have:
<com.rarepebble.colorpicker.ColorPreference android:key="go_circle_colour_pref_key" android:title="@string/goColour" app:colorpicker_showAlpha="true" />
I have tried:
putting default colours in the preferences.xml, e.g.
<!--android:defaultValue="#f00"-->
editor.putInt("go_circle_colour_pref_key",Integer.parseInt("0x00ff00"));
editor.putInt("go_circle_colour_pref_key",0x00ff00);
editor.putInt("go_circle_colour_pref_key",Color.parseColor("#00ff00");
editor.putString("go_circle_colour_pref_key","#00ff00";
editor.putString("go_circle_colour_pref_key","#0f0";
editor.putString("go_circle_colour_pref_key","0x00ff00";
If I give the color-picker preference in xml a key that doesn't actually get used (initialised in activityMain), then the colour picker works OK. I seem to be initialising the key incorrectly.
The text was updated successfully, but these errors were encountered: