How to Set the Text in an EditText, in any method, in java


1. Make sure you have added your EditText to your project.

2. Create and Find the EditText using ID, named myEditText.

3. You can now add the setText line of code to any method. For example, in an onClickButton method.

  public void onClickButton(View v) { //needs import android.view.View;

       myEditText.setText("This is the new text!");
 }

4. Compile and run!