Reputation: 6922
My manifest.xml part as below:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14" />
<activity android:name="MyActivity" android:screenOrientation="sensor" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" ></activity>
And in MyActivity code as below:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.clear();
MenuInflater i = getMenuInflater();
i.inflate(R.menu.my_menu, menu);
return super.onPrepareOptionsMenu(menu);
}
my_menu.xml as below:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/test" android:icon="@drawable/test" android:title="test" android:showAsAction="ifRoom|withText"></item>
</menu>
I want to let show old menu bar while sdk before 11.
And show action bar while after sdk 11.
Now I can show menu bar before sdk 11, but not show soft menu button or action bar after sdk 11.
How can I modify it?
Upvotes: 1
Views: 1125
Reputation: 1865
You have to change
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
to
android:theme="@android:style/Theme.Light.NoTitleBar"
Also you have here Google - Action Bar
Upvotes: 1
Reputation: 126
remove this following line from activity as it hides actionbar
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
Upvotes: 1
Reputation: 613
From android.developer.com: (http://developer.android.com/guide/topics/ui/actionbar.html)
Remaining backward-compatible
If you want to provide an action bar in your application and remain compatible with versions of Android older than 3.0, you need to create the action bar in your activity's layout (because the ActionBar class is not available on older versions).
To help you, the Action Bar Compatibility sample app provides an API layer and action bar layout that allows your app to use some of the ActionBar APIs and also support older versions of Android by replacing the traditional title bar with a custom action bar layout.
And here is the sample code, hope this helps you out! Sample: http://developer.android.com/tools/samples/index.html
Upvotes: 1