我刚开始使用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.setDisplayShowTitleEnabled(false)
。 - Matthias Robbers