近来不少同学在修改主题时遇到,切换主题,部分页面不更新的问题,下面来介绍一种切换主题时,主动刷新的方法:
1、监听主题切换的广播
private static final String DATA_TYPE_TMOBILE_STYLE = "vnd.tmobile.cursor.item/style";
private static final String DATA_TYPE_TMOBILE_THEME = "vnd.tmobile.cursor.item/theme";
private static final String ACTION_TMOBILE_THEME_CHANGED = "com.tmobile.intent.action.THEME_CHANGED";
try {
IntentFilter tMoFilter = new IntentFilter(ACTION_TMOBILE_THEME_CHANGED);
tMoFilter.addDataType(DATA_TYPE_TMOBILE_THEME);
tMoFilter.addDataType(DATA_TYPE_TMOBILE_STYLE);
context.registerReceiver(mBroadcastReceiver, tMoFilter);
} catch (android.content.IntentFilter.MalformedMimeTypeException e) {
Log.e(TAG, "Could not set T-Mo mime types", e);
}
2、在广播中主动刷新资源
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if (ACTION_TMOBILE_THEME_CHANGED.equals(intent.getAction())) {
refreshRes();
}
}
}