I have a problem with code in Android Studio.
I have ActivityA
and ActivityB
.
In ActivityA
I have buttons. ActivityB
is about settings. For example, I can choose the theme of the app. All done using SharedPreferences
.
If I change theme to DARK with this code:
Button Settings = (Button) findViewById(R.id.settings);
Settings.setTextColor(Color.BLACK);
Settings.setBackgroundResource(R.drawable.shapestylethis3);
and I press back to go o ActivityA
- then buttons are changed.
Now when I'm in ActivityB
and I wanna change back for theme LIGHT
then I would like to get back this default button on ActivityA
:
style="@android:style/Widget.Button.Small"
But I don't know how to achieve that. ActivityB
is changing right after clicking the button "save" because apart from saving to SharedPreferences
I used also recreate();
in onClick
.
But when I put recreate()
in the onResume
in ActivityA
, then it's like an infinite loop. I will be really thankful for helping me finding a solution.
Thank you in advance.