读书人

动态的批改自定义custom title

发布时间: 2012-09-20 09:36:50 作者: rapoo

动态的修改自定义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); 
?

?

读书人网 >软件架构设计

热点推荐