选项菜单没有出现在某些设备上的操作栏

问题描述:

我在操作栏中有一个选项菜单,并且它没有出现在具有硬件菜单按钮的某些设备上。尽管有硬件按钮,我必须让它出现在操作栏中... 我该怎么做?选项菜单没有出现在某些设备上的操作栏

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) { 
} 
+0

什么进口是田野? – 2014-09-24 07:38:26

+0

import java.lang.reflect.Field – 2014-09-24 07:40:06