I have developed an android app that mainly targets smartphones. However in tablet emulator I see that it works on android 3.x, too.
However there is one little problem. The user cannot open OptionsMenu when he clicks on the menu button. As you know on the smartphone a menu appears from the bottom. But on tablet nothing happens.
I have read this http://developer.android.com/guide/topics/ui/menus.html#options-menu but still cannot figure out how to manage this. My app has a custom action bar.
My code is quite straight forward. In main activity:
@Override
public boolean onCreateOptionsMenu(Menu men) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.layout.menu, men);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
//...
}
}
And the prefs activity:
public class MdPrefsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesName(
MdSharedPrefs.PREFS_NAME);
addPreferencesFromResource(R.xml.prefs);
}
}
MdSharedPrefs class just contains some getters and setters to retrieve/write the pref values.
Any ideas how I can show the OptionsMenu on tablet?
As the documentation said:
So for Android 3.0 or higher you can see only the menu items in the
ActionBar
.It is also important to notice that:
But be aware that the
ActionBar
is visible only if you don't have an application or activity theme that explicitly hides it like