0

On line 3 R.id.edit_message compiler said edit_message cannot be resolve or is not a feild

public void sendMessage(View view) {
    Intent intent = new Intent(this, Display1MessageActivity.class);
    EditText editText = (EditText) findViewById(R.id.edit_message);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity(intent);
}

The intent should follow by line 2 "@+id/edit_message" in my xml file

   <EditText
    android:id="@+id/edit_message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="@string/edit_message" />

Any suggestion that how I can solve this problem plz

In case it helps, this is my manifest and string

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
        android:name="com.example.myfirstapp.MainActivity"
        android:label="@string/app_name" >

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <activity
    android:name="com.example.myfirstapp.Display1MessageActivity"
    android:label="@string/title_activity_display1_message"
    android:parentActivityName="com.example.myfirstapp.MainActivity" >
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application></manifest><?xml version="1.0" encoding="utf-8"?>

<string name="app_name">MyFirstApp</string>
<string name="action_settings">Settings</string>
<string name="button_send">Send</string>
<string name="title_activity_main">MainActivity</string>
<string name="hello_world">Hello world!</string>
<string name="title_activity_display1_message">My Message</string>

Blackbelt
  • 156,034
  • 29
  • 297
  • 305

1 Answers1

0

Go to Project Menu -> Select Clean and Press Ok

and it will be done.

Anish Shah
  • 7,669
  • 8
  • 29
  • 40
  • problem not solved, any other suggestion? Or shall I provide my full code? – user3406681 Mar 11 '14 at 15:28
  • remove `import android.R` and also do as I mentioned in the answer. Hope it works. Basically, this error is raised because there is no `R.java` file in the `gen` directory. – Anish Shah Mar 11 '14 at 15:38
  • thank you for helping, problem solved. would you mind to tell me why after deleted **import android.R"** will works ? is it because I hv miss out something during the process? – user3406681 Mar 11 '14 at 16:18
  • Hope this question helps you. http://stackoverflow.com/questions/15309941/import-android-r-in-eclipse-why – Anish Shah Mar 11 '14 at 16:26