第3行R.id.edit_message
编译器说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);
}
意图应该在第2行和第34行之后; @ + id / edit_message"在我的xml文件中
<EditText
android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
任何建议我如何解决这个问题PLZ
如果它有帮助,这是我的清单和字符串
<?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>
答案 0 :(得分:0)
转到项目菜单 - &gt;选择清洁并按确定
将会完成。