I am trying to create my first application using the tutorial provided by android in Eclipse.
I did everything that is said, but I get an error message ... "the menu cannot be resolved or is not a field." The textbook says nothing about the menu, and I'm sure I did nothing with it. In the line he complains about, I am marked in the comment.
package com.example.my.first.app; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); <!--this line--> return true; } }
This is the main activity page that the teacher asked to change, shown below ...
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <EditText android:id="@+id/edit_message" android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content" android:hint="@string/edit_message" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_send" /> </LinearLayout>
Sending tips that I found on other issues, I tried to click on it and turn on what I had ever asked, for which it is “Create a menu field” in type “R” or “Create permanent menu” in type 'P' I did this both separately and every time I save the project so that it is rebuilt, it automatically deletes the line that was included.
For the field, this was done. - public static menu "Object"; For a constant, this was done. - public static final String menu = null;
So now I am a little stuck and would like to receive the necessary help.
android eclipse
Shocker_33
source share