【发布时间】:2014-08-19 11:07:51
【问题描述】:
我在我的项目中实现了自定义 actionBar。它有两个 Textview 我想以编程方式更改文本如何做到这一点。我尝试了以下代码,但我的操作栏没有变化
this.getActionBar().setDisplayShowCustomEnabled(true);
this.getActionBar().setDisplayShowTitleEnabled(false);
this.getActionBar().setDisplayUseLogoEnabled(false);
this.getActionBar().setDisplayHomeAsUpEnabled(false);
this.getActionBar().setDisplayShowHomeEnabled(false);
this.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
LayoutInflater inflator = LayoutInflater.from(this);
View v = inflator.inflate(R.layout.actionbarlayout, null);
mSiteName= ((TextView)v.findViewById(R.id.sitenameastitle));
mSiteName.setText("helloooo");
this.getActionBar().setCustomView(v);
【问题讨论】:
-
你应该在提问之前先做一些搜索,但只是为了第一次推送,我在下面给出了一个代码。
标签: android custom-component android-actionbar-compat