Java 如何显示应用程序栏(菜单)xml文件

Java 如何显示应用程序栏(菜单)xml文件,java,android,xml,appbar,Java,Android,Xml,Appbar,我试图找到一种在我的应用程序栏中显示菜单xml文件的方法,但我被卡住了,所以我请求帮助 到目前为止,我得到的是: 主要活动xml: <android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?

我试图找到一种在我的应用程序栏中显示菜单xml文件的方法,但我被卡住了,所以我请求帮助

到目前为止,我得到的是:

主要活动xml:

<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
以及菜单文件夹中的xml文件

目前,应用程序栏中唯一显示的是应用程序名称。(应该还有一个未显示的设置项目)

我必须尊重xml文件所在的位置,还是必须编辑另一个xml文件?还是我完全错过了什么

我遵循了本指南中的步骤:


如果你需要我丢失的任何信息,请询问。谢谢你的帮助。

我忘了添加这样的内容:

    @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_activity_actions, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
    @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_activity_actions, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}