I'm new to Android Studio and Android development. So I was following the tutorial given by developer.android.com and I'm having an error in this line : EditText editText = (EditText) findViewById(R.id.editText);
The error is saying that : cannot find symbol variable editText .
This is part of my code :
import android.os.Bundle;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
public void sendMessage(View view){
EditText editText = (EditText) findViewById(R.id.editText);
String message = editText.getText().toString();
}
}
Make sure that you have assigned the id
for your EditText
in the activity_main.xml
as below:
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With