I have implemented the action bar in my application. I have implemented the action bar menu using a support library. I want to show the same menu while clicking a menu button on an android device. Can anybody tell me how to do this?
I can get you as far as detecting the menu key. Depending on device there may be overflow of actionbar menu that appears when the menu key is pressed. There are a lot more questions for a complete answer it might be as simple as building the menu options programmatically versus using a res/menu/menu.xml file.
Below I force full screen in an app when the menu key is pressed.
@Override
public boolean onKeyDown(int keycode, KeyEvent e) {
switch (keycode) {
// show the bar if the menu button is pressed
case KeyEvent.KEYCODE_MENU:
isFullScreen = false;
this.setFullScreen(isFullScreen);
return false;
}
return super.onKeyDown(keycode, e);
}
@Override
public void setFullScreen(boolean isChecked) {
if (!isChecked) {
if (Build.VERSION.SDK_INT < 16) {
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
bar.show();
} else {
if (Build.VERSION.SDK_INT < 16) {
getWindow()
.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
bar.hide();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.