2012-02-27 96 views

回答

1
ViewConfiguration.get(context).hasPermanentMenuKey() 
0

菜单按钮是somewhat outdated,也许你想重新考虑并坚持溢出菜单?顺便说一下,你知道吗http://actionbarsherlock.com/

+0

Android 4.0的动作条隐藏在其上具有HW菜单按钮的设备的溢出菜单。我想模仿这种行为。我不能使用系统的ActionBar或ActionBarSherlock,因为我需要一个非常特殊的行为,这是ABS不可能实现的。 – fhucho 2012-02-27 21:19:49

+0

好吧,只是认为你可以分叉ABS并在其上实现你的特定行为。你有没有检查Android的源代码? – 2012-02-27 21:25:22

+0

不,但我会尝试:)分叉ABS看起来像很多工作... – fhucho 2012-02-28 11:49:33

0
try { 
    ViewConfiguration config = ViewConfiguration.get(this); 
    Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); 


     if (menuKeyField != null) { 
      menuKeyField.setAccessible(true); 
      menuKeyField.setBoolean(config, false); 
     } 
    } catch (Exception e) { 
     e.printStackTrace(); 

} 

}

+0

在onCreate方法中使用此代码。 – 2014-08-21 10:09:02