I'm going to get a color using volley request (I need to use volley, not sharedpreferences for this.)
the problem is to set it after my setContentView.
style.xml:
<style name="Red" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#ff0000</item>
<item name="colorPrimaryDark">#000000</item>
<item name="colorAccent">#ff0000</item>
</style>
my oncreate:
protected void onCreate(Bundle savedInstanceState) {
String color = "Red"; // I need to get this color using volley, so I cannot set red here, but if I don't set it here, it will not work.
Utils.setThemeToActivity(this, color); // same
super.onCreate(savedInstanceState);
setContentView(R.layout.name);
}
it is working because I set color as red. but I need to get this red from volley so I cannot put it in the first line of oncreate as it is now.
any ideas how can I pass red to Utils.setTheme
there?
my Utils:
public class Utils {
public static String SIZE="";
public static boolean settingChanged=false;
public static String THEME="";
public static void setThemeToActivity(Activity act, String color ) {
try {
if(Utils.THEME.equalsIgnoreCase("Yellow")) {
act.setTheme(R.style.Yellow);
}
if(Utils.THEME.equalsIgnoreCase("Red")) {
act.setTheme(R.style.Red);
}
if(Utils.THEME.equalsIgnoreCase("Blue")) {
act.setTheme(R.style.Blue);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}