遗留应用程序的操作溢出按钮根本未显示在导航栏中

时间:2013-10-28 12:30:28

标签: android android-actionbar android-menu

我想在我的应用程序中显示动作溢出按钮

操作溢出按钮: are these:

我按照these指示操作:

  • 如果将minSdkVersion或targetSdkVersion设置为11或更高, 系统不会添加旧版溢出按钮。
  • 否则,系统会在添加旧版溢出按钮时 在Android 3.0或更高版本上运行。
  • 唯一的例外是,如果将minSdkVersion设置为10或更低, 将targetSdkVersion设置为11,12或13,并且不使用ActionBar, 系统将在运行您的应用程序时添加旧版溢出按钮 在Android 4.0或更高版本的手机上。

所以我就像读了清单的最后一点一样。

以下是我的应用中的设置:

活动:我打印出我是否有菜单按钮,我得到“否”的结果

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (ViewConfiguration.get(this).hasPermanentMenuKey()) {
        Log.i("MenuButtonIsAvailable", "YES");
    } else {
        Log.i("MenuButtonIsAvailable", "NO"); //I got this on logcat.

    }

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

清单摘录:我将minSdkVer设置为10,将targetSdkVer设置为11,这是显示旧版溢出菜单按钮的首选选项。

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="11" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

//...

styles.xml:我以我应用的风格关闭了ActionBar。

<resources>


    <style name="AppBaseTheme" parent="android:Theme.Light">

    </style>


    <style name="AppTheme" parent="AppBaseTheme">

       <item name="android:windowActionBar">false</item>
    </style>

</resources>

在所有这些方法之后,我没有看到溢出菜单按钮。 我应该在我的设置中修改什么?

1 个答案:

答案 0 :(得分:0)

页面http://developer.android.com/design/patterns/compatibility.html 说它只会出现在应用

  

是为Android 2.3或更早版本构建的

但是android:targetSdkVersion="11"的{​​{3}} - &gt; Android 3.0

build