首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

动态的批改自定义custom title

2012-09-20 
动态的修改自定义custom title在android中 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.la

动态的修改自定义custom title

在android中 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.text_title);???? 使用上面的话时 他所产生的并不是把以前的用现在的替换只是用?? R.layout.text_title放在了默认样式的上面,如果你想通过一个按钮修改标题
以及view上的消息有两种方法:

private void setCustomTitleFeatureInt(int value) {         try {        // retrieve value for com.android.internal.R.id.title_container(=0x1020149)               int titleContainerId = (Integer) Class.forName(                        "com.android.internal.R$id").getField("title_container").get(null);                // remove all views from titleContainer                ((ViewGroup) getWindow().findViewById(titleContainerId)).removeAllViews();                  // add new custom title view                     getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, value);                  } catch(Exception ex) {                         // whatever you want to do here..    }??? } 
?



这种方法是取消以前的 不过这种方法可靠性不好
2.你可以用隐藏的方式:

findViewById(R.id.custom_title_1).setVisibility(View.GONE);getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_2); 
?

?

热点排行