每当我尝试向操作栏添加按钮时,这些项目都会添加到溢出菜单下

Whenever I try to add a button to my actionbar, the items are added under the overflow menu

我正在尝试向我的操作栏添加一个简单的按钮,但是当我尝试使用以下代码时,这些项目被添加为溢出菜单下的项目,而不是操作栏本身。任何帮助将不胜感激,

雅各布

这是我的 Java:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_review, menu);


    return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle presses on the action bar items
    switch (item.getItemId()) {
        case android.R.id.home:

            super.onBackPressed();
            return true;



        default:
            return super.onOptionsItemSelected(item);

    }
}

和我的 XML:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:yourapp="http://schemas.android.com/apk/res-auto">


    <item android:id="@+id/seda"
        android:icon="@drawable/redpinreal"
        android:title="Hello Worldh"
        android:showAsAction="withText|always"/>

</menu>    

我也启用了这个:

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

您的部分代码(android:showAsAction,而不是 yourapp:showAsAction)正在尝试使用本机操作栏。您的部分代码(getSupportActionBar(),而不是 getActionBar())正在尝试使用 appcompat-v7 操作栏向后移植。 选择一个并坚持下去。