android机器有实体菜单键界面右上角始终无法显示问题
动态增加菜单
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.main, menu);
menu.add(1, 1, 1, "1");
menu.add(1, 2, 2, "2");
menu.add(1, 3, 3, "3");
menu.add(1, 4, 4, "4");
return true;
}
重点屏蔽物理菜单键:
try {
ViewConfiguration mconfig = ViewConfiguration.get(this);
java.lang.reflect.Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if(menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(mconfig, false);
}
} catch (Exception ex) {
}