Android learning — cannot resolve symbol ‘EditText‘

EditText editText =(EditText)findViewById(R。 id.editText ); in “((R id.editText ))”Error cannot resolve symbol ‘EditText’

Today, there was an error when learning from the Android Studio development document. When starting another activity and building an intent, https://developer.android.google.cn/training/basics/firstapp/starting-activity#java

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

Solution, view activity_ main.xml , text edit box section

<EditText
    android:id="@+id/editTextTextPersonName3"

Change the EditText in the SendMessage method to the corresponding, I’m here edittexttextpersonname3, as shown in the figure

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

Read More: