android中的菜单如何工作

android中的菜单如何工作,android,android-layout,android-menu,Android,Android Layout,Android Menu,我读了不同的帖子,不同的东西,却从未找到答案。我试图创建一个简单的菜单,在我的主要活动的右上角有“…” 我创建我的XML <?xml version="1.0" encoding="utf-8"?> <menu xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" > <i

我读了不同的帖子,不同的东西,却从未找到答案。我试图创建一个简单的菜单,在我的主要活动的右上角有“…”

我创建我的XML

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"

    >

    <item android:title="Settings"
        android:icon="@mipmap/ic_settings" android:id="@+id/MnuSettings"  />
</menu>
我尝试在我的主布局中包含

我确信我们可以将菜单添加到所有布局中,但我不知道如何添加,什么也找不到

谁能帮帮我吗


我是否需要在manifest.xml中为菜单创建一些内容。我是否需要在布局文件的xml中添加一些内容。。。永远找不到答案-(

假设您的菜单xml名为
menu\u main
。将其更改为:


我在下面的教程中找到了我要搜索的内容

我的主布局文件夹中缺少工具栏

<android.support.v7.widget.Toolbar
    android:id="@+id/SettingToolBar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/AlertDialog.AppCompat.Light">
最后 将调用创建选项菜单(菜单菜单菜单)

教程

还有这个,可能还有上千个
<item android:title="Settings"
    android:icon="@mipmap/ic_settings" 
    android:id="@+id/MnuSettings"  
    android:title="Settings"
    app:showAsAction="never"/>
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }
<android.support.v7.widget.Toolbar
    android:id="@+id/SettingToolBar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/AlertDialog.AppCompat.Light">
 Toolbar toolbar = (Toolbar)findViewById(R.id.SettingToolBar);
setSupportActionBar(toolbar);