Android4.0系统以上程序不出现菜单键的问题解决

去掉targetSdkVersion

或改为targetSdkVersion =13或更小。。

 

不改targetSdkVersion的办法:
在onCreate() 里setContentView()之后加入如下代码即可。
try {
    window.addFlags(WindowManager.LayoutParams.class.getField("FLAG_NEEDS_MENU_KEY").getInt(null));
  }
  catch (NoSuchFieldException e) {
    // Ignore since this field won't exist in most versions of Android
  }
  catch (IllegalAccessException e) {
    Log.w(TAG, "Could not access FLAG_NEEDS_MENU_KEY in addLegacyOverflowButton()", e);
  }

posted @ 2013-07-08 13:37  ConquerMobileApp  阅读(378)  评论(0编辑  收藏  举报