我是 ActionBarSherlock 的新手,有两个问题:
首先,我只想能够设置操作栏的标题,但是当我这样调用它时它不起作用:
final ActionBar actionBar = (ActionBar) findViewById(R.id.actionBar);
actionBar.setTitle("test title");
相应的 xml 对象如下所示:
<com.myapp.prototype.ActionBar
android:id="@+id/actionBar2"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
(这是根据 github 示例建模的:https://github.com/johannilsson/android-actionbar/blob/master/actionbarexample/src/com/markupartist/android/actionbar/example/HomeActivity.java)。在网络上的其他地方,我看到了对 getSupportActionBar() 的引用,但我不清楚如何或在何处调用它。
其次,在另一个地方我只想能够完全隐藏 Activity 的标题栏。我试图通过调用来做到这一点:
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
但我什至无法编译它。我得到的错误是:
"The method setDisplayShowTitleEnabled(boolean) is undefined for the type
ActionBar."
在这两种情况下,我猜 Actionbar Sherlock 覆盖都与问题有关。关于如何使这项工作有任何建议吗?
非常感谢。
最佳答案
设置ActionBar
标题
setTitle("Title")
隐藏和显示ActionBar
getSupportActionBar().hide();
getSupportActionBar().show();
关于android - Action 条 Sherlock : Setting and hiding title bar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10807561/