Reputation: 2987
I am new to work with android tablet api level 12. I have created 7 inches avd with 1024*600 screen resolution. I have implemented sample application for get the option menus on my screen and back button. I am unable to see option button and back button on my emulator.
I have implemented for option menu code as follows:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.icon: Toast.makeText(this, "You pressed the icon!", Toast.LENGTH_LONG).show();
break;
case R.id.text: Toast.makeText(this, "You pressed the text!", Toast.LENGTH_LONG).show();
break;
case R.id.icontext: Toast.makeText(this, "You pressed the icon and text!", Toast.LENGTH_LONG).show();
break;
}
return true;
}
Upvotes: 1
Views: 4907
Reputation: 11
For windows 10 you have to open your emulator, then press Ctrl + M and the menu will show.
Upvotes: 1
Reputation: 38177
Short update: a current list of commands is found at https://developer.android.com/studio/run/emulator.html#tasks.
For the menu, you are supposed to use Ctrl-M (on a Mac: Command-M).
Upvotes: 1
Reputation: 7881
As you said "I am unable to see option button and back button on my emulator" SO its does not make a sense that you have posted your code because you can't changes the hardware as programmatically.
and
Upvotes: 1
Reputation: 6954
Ordinary options menus will appear regardless of Android version. If you have:
android:targetSdkVersion="11"
then the options menu will appear in the action bar on Android 3.0+ devices. All items in the options menu will be available when clicking the "overflow" button in the upper-right corner. Your options menu will appear normally on Android 1.x and 2.x devices, even if you have android:targetSdkVersion="11" in your manifest element.
If you overrode the MENU button to have other behavior, you will need to create some other trigger for that behavior for API Level 11 and higher. Overriding the MENU button was never a good idea to begin with, and as you can see, it is even less of a good idea now. I know of no way to get a MENU button on an Android 3.0 device if you have android:targetSdkVersion="11".
Upvotes: 1