I'm new to android programming and I found out that menu are not available for android 3.0 and up. And suggestions is to use Action Bar. So I have the following in my AndroidManifest.xml
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="Main" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> In my main.xml for menu/action bar:
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/homeMenu" android:orderInCategory="100" android:title="@string/home" android:showAsAction="ifRoom"/> <item android:id="@+id/searchMenu" android:orderInCategory="200" android:title="@string/search" android:showAsAction="ifRoom"/> <item android:id="@+id/exitMenu" android:orderInCategory="300" android:title="@string/exit" android:showAsAction="ifRoom"/> </menu> But it only display activity title in action bar for Android ICS. What I want if possible is to have the menu for Android < 3.0 and Action Bar for Android 3.0 and up. Or if there are better approach for this.
I have onCreateOptionsMenu in my main activity:
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } The menu works perfectly for Android 2.3.6 but Action Bar didn't display as I expected for Android ICS.
Thanks