问题
I am Working on One Application which has Settings
Screen which Opens When User Click on OptionMenu Shortcut which shows on Devices as Default Button or any other Sign.
it Works fine when there is default menu button in device but not getting any Sign for Menu Option when there is not any default menu button in devices.
My Code is as Below:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_setting, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.btnSettingMenu:
Intent intent = new Intent(MainActivity.this,
RegisterActivity.class);
intent.putExtra("From", "MainActivity");
startActivity(intent);
break;
default:
break;
}
return true;
}
I have refered to Link HERE but could not able to solve my problem.
Point I would like to add is: I am getting the Menu Option in Emulator when i am pressing PageUp
or F2
.
But when the Device Does not have Default Menu Button it is not Showing with any other indication as three dots or some other way.
My Question : How can User Go to my Setting Screen if he is not Finding Option Menu Sign in real devices Like Nexus 7?
Thanks in Advance.
回答1:
For showing Menu icon in above 4.0 Devices
:
if you have declared android:targetSdkVersion="xx"
Either remove it if you don't required.
OR
If you want to declare it,then set value 0f xx
below 14
i.e.android:targetSdkVersion="13".
Hope it will work for you.
回答2:
Try this:
Please remove this two line in your java class.
// hide titlebar of application // must be before setting the layout requestWindowFeature(Window.FEATURE_NO_TITLE); // hide statusbar of Android // could also be done later getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Please remove this two line in your AndroidManifest.xml.
To hide the titlebar of your application you can use the predefined style
android:theme=”@android:style/Theme.NoTitleBar”.
or if you also want to hide the statusbar of your application use
android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”.
来源:https://stackoverflow.com/questions/14000784/not-showing-any-sign-of-menu-button-when-there-is-not-any-default-menu-button-in