只是一个提示,我想:
之前finish();
呼叫
setResult(AnIntegerThatNotifiesThePreviousActivitiesToChangeTheme);
现在,在所有的活动,实现onActivityResult
protected void onActivityResult(int request, int result, Intent data) {
if(result == AnIntegerThatNotifiesThePreviousActivitiesToChangeTheme)
{
//update the current theme
}
}
另一种解决方案(更好):
实现一个类,保存主题:
public class CurrentThemeHolder {
private CurrentThemeHolder() {
}
private static instance;
public static getInstance() {
if(instance == null)
return new CurrentThemeHolder();
else
return instance;
}
private int mTheme; //identifier of the theme
public getTheme() {
return mTheme;
}
public setTheme(int newTheme){
mTheme = newTheme;
}
}
现在,让你的生命活动扩展这个ThemeActivity:
public class ThemeActivity extends Activity {
private int mTheme;
protected void onResume() {
if(mTheme != CurrentThemeHolder.getInstance().getTheme()) {
//do what you should do to set the theme
mTheme = CurrentThemeHolder.getInstance().getTheme();
//everytime you set the theme save it
//this maybe should be done in onCreate()
}
}
}
你好警长,我想从您知道是否有可能是任何解决方案,我从网上得到的颜色代码,并根据我可以改变我的所有按钮运行时的颜色而不去所有的特定按键和应用背景颜色,莫不是任何解决方案使用主题或风格?请分享您的任何建议。 – MKJParekh 2014-03-20 07:54:23
你有无限的色彩吗?或只是有限的一套颜色? – 2014-03-21 15:15:30
我做有限的20种颜色的发言权,但那些20会从服务器上下载的,因此可能会有所不同,从一个时间到另一个,总之颜色是15-20左右(不是修复),以及那些颜色代码也没有解决。其中一个用户已经建议使用CustomViews http://stackoverflow.com/questions/22529646/android-app-apply-color-theme-dynamically-at-runtime – MKJParekh 2014-03-22 04:40:24