アンドロイドアプリケーションでオプションメニューを実装するにはどうすればよいですか? Android Developerからコードを試しましたが、エラーが発生します。これらのような:要素メニューはを宣言する必要があります。ここに私のコードはAndroid Studioでオプションメニューを実装する
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:icon="@drawable/ic_new_game"
android:title="@string/new_game"
android:showAsAction="ifRoom"/>
<item android:id="@+id/help"
android:icon="@drawable/ic_help"
android:title="@string/help" />
</menu>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lucavanraalte.test" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
をご確認くださいあなたの(YourActivity)にxmlあなたの活動レイアウトを作成する場所 – Strider
あなたの質問でコードを書式設定したかどうかはわかりませんが、どのメニューファイルも 'menus'サブディレクトリの' xml'ファイルを持つ必要があります。それはマニフェストの一部であってはなりません。 – PPartisan
どこに置く必要がありますか?新しいフォルダを作成する必要はありますか?上記の画像を参照してください – Lucafraser