我在操作栏中有一个选项菜单,它不会出现在某些具有硬件菜单按钮的设备上。尽管有一个硬件按钮,我必须让它出现在操作栏中...... 我该怎么做?
最佳答案
将其放入您的 onCreate
方法中:
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class
.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception ex) {
}
关于android - 在某些设备上,选项菜单不会出现在操作栏中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26010876/