ActionBar not showing, only old menu

343 views
Skip to first unread message

Sam Shaw

unread,
Sep 19, 2011, 12:02:39 AM9/19/11
to ActionBarSherlock
Hi,

I'm trying to use ActionBarSherlock in my application, but I'm having
some troubles with getting it to actually show.
My activity is extending FragmentMapActivity as I'm making a map based
app.
The imports for the menu items are the sherlock ones, so I'm be
overriding onCreateOptionsMenu(Menu) correctly.

Now what happens is when I either inflate or manually add menu items
to the menu, it doesn't show the actionbar. It still stays with the
basic menu that only appears when you press the menu button. I've
tried just having one item, defined in xml or adding it through code.
Neither approach is working.

I've used MapActivityActionBar from the samples as a reference to
check I've got the right methods being called and so on. Everything
seems to check out between my activity and the sample.

I'm also targetting Android 2.2, and the sample applications work in
the 2.2 emulator, so I can see it working.

Here are the important parts:

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = (MenuInflater) getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
return super.onCreateOptionsMenu(menu);
}

And menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:title="@string/S_menu_hydrants" android:id="@integer/
menu_hydrant"
android:enabled="true" android:visible="true"
android:showAsAction="always" android:icon="@drawable/hydrant"></item>

<item android:id="@integer/menu_permit" android:title="@string/
S_menu_permits"
android:enabled="true" android:visible="true"
android:showAsAction="always" android:icon="@drawable/permit"></item>

<group android:checkableBehavior="single">
<item android:id="@+id/item1" android:title="@string/S_menu_view"
android:showAsAction="ifRoom">
<menu>
<item android:title="@string/S_menu_sat" android:id="@integer/
menu_sat" android:showAsAction="ifRoom"></item>
<item android:title="@string/S_menu_map" android:id="@integer/
menu_map" android:showAsAction="ifRoom"
android:checked="true"></item>
<item android:title="@string/S_menu_centre_location"
android:id="@integer/menu_centre_location"
android:showAsAction="ifRoom"></item>
</menu>
</item>
</group>

<item android:title="@string/S_menu_preferences" android:id="@integer/
menu_preferences"
android:enabled="true" android:visible="true"
android:showAsAction="ifRoom"></item>
</menu>


Is there something obscure that I haven't set?

Jake Wharton

unread,
Sep 19, 2011, 10:04:01 AM9/19/11
to actionba...@googlegroups.com
Have you set the theme in the manifest to Theme.Sherlock or Theme.Sherlock.Light? If you have a custom theme it needs to inherit from one of the aforementioned two also.

Sam Shaw

unread,
Sep 19, 2011, 7:53:18 PM9/19/11
to ActionBarSherlock
Yes, that was exactly it. Thank you.
Reply all
Reply to author
Forward
0 new messages