动作栏没有在android 4.2中显示

时间:2014-08-02 08:16:46

标签: android android-layout android-actionbar

因为android 3.0中引入了操作栏 我的应用程序在android 4.2中显示操作栏,而不是在2.3中显示

我试图在Android 3.0及以上的操作栏中显示菜单项作为溢出图标.. 但不幸的是我的应用程序没有在任何Android版本中显示操作栏。

请帮助我..我想显示所有Android版本的操作栏,我想将菜单项显示为溢出图标。

我正在尝试将此代码用于操作栏溢出图标。

 try {
            ViewConfiguration config = ViewConfiguration.get(this);
            java.lang.reflect.Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
            if(menuKeyField != null) {
                menuKeyField.setAccessible(true);
                menuKeyField.setBoolean(config, false);
            }
        } catch (Exception ex) {
            // Ignore
        }

我在setContentView

之后在我的主要活动中添加了这段代码

0 个答案:

没有答案
相关问题