private void switchTitle(int titleID, String titleText, Boolean titleGoBack) {
getWindow().setFeatureInt(getWindow().FEATURE_CUSTOM_TITLE, titleID);
if (titleText.length() > 0) {
menuTitleTv = (TextView) findViewById(R.id.gTvMenuTitle);
menuTitleTv.setText(titleText);
// titleText1 = titleText;
// new Thread(runnable).start();
Log.i(TAG, "±ê????????" + titleText);
}
if (titleGoBack) {
ImageView backIv = (ImageView) findViewById(R.id.gIvGoBack);
backIv.setOnClickListener(this);
}
}
方法中第一次使用setText可以生效,之后再次调用方法,setText就无效,使用线程方法也无效,何解???
------解决思路----------------------
stackoverflow不愧是大神云集
http://stackoverflow.com/questions/820398/android-change-custom-title-view-at-run-time
大概意思应该是反射获取那个布局,清空再重来一次……
——————
或者试试隐藏
findViewById(R.id.custom_title_1).setVisibility(View.GONE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_2);