I'm new to ActionBarSherlock, and am having two problems:
First, I just want to be able to set the title of the action bar, but it doesn't work when I call it like this:
final ActionBar actionBar = (ActionBar) findViewById(R.id.actionBar);
actionBar.setTitle("test title");
Where the corresponding xml object looks like this:
<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" />
(This is modeled after the github example: https://github.com/johannilsson/android-actionbar/blob/master/actionbarexample/src/com/markupartist/android/actionbar/example/HomeActivity.java). In other places on the web, I see reference to getSupportActionBar(), but I'm not clear how or where to call this.
Second, in another place I just want to be able to hide the Activity's title bar altogether. I'm trying to do this by calling:
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
but I can't even get this to compile. The error I'm getting is:
"The method setDisplayShowTitleEnabled(boolean) is undefined for the type
ActionBar."
In both cases, I guess the Actionbar Sherlock overrides are involved in the problem. Any suggestions how to make this work?
Thanks very much.
ActionBar
titlesetTitle("Title")
ActionBar
getSupportActionBar().hide();
getSupportActionBar().show();
You seem to be mixing up two different ActionBar implementations. ActionBarSherlock is an extension of the compatibility library provided by Google. The methods used with ActionBarSherlock are almost identical to the native ActionBar found in Android 3.0+ http://actionbarsherlock.com/
The Github link provided (and code you are using) is a custom implementation of an actionbar https://github.com/johannilsson/android-actionbar.
I would advise you use ActionBar sherlock and follow the usage guide here http://actionbarsherlock.com/usage.html
There is also an ActionBarSherlock getting started video here http://www.youtube.com/watch?feature=player_embedded&v=4GJ6yY1lNNY
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With