I'm just a beginner with android and trying to develope an app with all kind of basis features to get familiar with them. I'm trying to safe a setting of the textview color, chosen by the user. This color is lost when the orientation changes. I've read multiple threads about how to save things for orientation change but all those examples are with strings or boolean etc. saving activity state
I want to save a value from an xml file. So I have to save a piece of code that sets the color and not a primative datatype.
Part of the code that sets the color:
public void onClick(DialogInterface dialog, int item) {
switch(item){
case 0:
mWelcomeUser.setTextColor(getResources().getColor(R.color.purple_color));
break;
case 1:
mWelcomeUser.setTextColor(getResources().getColor(R.color.red_color));
break;
Part of the xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_color">#A420A0</color>
<color name="red_color">#FF0000</color>
<color name="green_color">#00FF00</color>
<color name="black_color">#000000</color>
<color name="blue_color">#0000FF</color>
<color name="grey_color">#828282</color>
</resources>
Now I want to save the colorsetting in onPause() and retrieve it in onResume(). But I cant figure this out. I've tried to put it in an int (color) something like this:
public void onPause(){
super.onPause();
color = mWelcomeUser.getCurrentTextColor();
}
public void onResume(){
super.onResume();
mWelcomeUser.setTextColor(color);
}
What is the easiest way to do this?
Thanks