http://blog.csdn.net/u014651216/article/details/53188698
private void showNagivationMenuKey() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
return;
}
if (Build.VERSION.SDK_INT <= 20) {
try {
int flags = WindowManager.LayoutParams.class.getField("FLAG_NEEDS_MENU_KEY").getInt(null);
getWindow().addFlags(flags);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
} else {
try {
Method setNeedsMenuKey = Window.class.getDeclaredMethod("setNeedsMenuKey", int.class);
setNeedsMenuKey.setAccessible(true);
int value = WindowManager.LayoutParams.class.getField("NEEDS_MENU_SET_TRUE").getInt(null);
setNeedsMenuKey.invoke(getWindow(), value);
} catch (Exception e) {
e.printStackTrace();
}
}
}