2012-02-27 88 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