title: How to clear the text from a EditText?
body: <p>I tried with <code>.getText().clear()</code> and <code>.setText("")</code>, but it doesn't work. Any idea why? I try to clear the text from all the EditTexts when the NewEventButton is pressed. If you have an idea, please add some code. Thanks!</p>
  
  <p>Java:</p>
  
  <pre><code>package com.exemple.android.calendar;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.text.Editable;
  import android.text.InputFilter;
  import android.text.Spanned;
  import android.text.TextWatcher;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.RadioButton;
  import android.widget.RadioGroup;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class NewEventActivity extends AppCompatActivity {
  
      //step 1.A:create objects
  
      public EditText DayEditText;
      public EditText MonthEditText;
      public EditText YearEditText;
      public EditText StartingHourEditText;
      public EditText StartingMinuteEditText;
      public EditText EndingHourEditText;
      public EditText EndingMinuteEditText;
      public EditText Title;
      public RadioGroup answer1;
      public Button NewEventButton;
  
      int day, month, year, s_hour, s_min, e_hour, e_min;
      String title;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.new_event_page);
  
          //Step 1.B: assign objects
  
          DayEditText = findViewById(R.id.DayEditText);
          MonthEditText = findViewById(R.id.MonthEditText);
          YearEditText = findViewById(R.id.YearEditText);
          StartingHourEditText = findViewById(R.id.StartingHourEditText);
          StartingMinuteEditText = findViewById(R.id.StartingMinuteEditText);
          EndingHourEditText = findViewById(R.id.EndingHourEditText);
          EndingMinuteEditText = findViewById(R.id.EndingMinuteEditText);
          Title = findViewById(R.id.TitleEditText);
          answer1 = findViewById(R.id.Answer1);
          NewEventButton = findViewById(R.id.CreateEventButton);
  
          DayEditText.setFilters(new InputFilter[]{new MinMaxFilter("0", "31")});
          MonthEditText.setFilters(new InputFilter[]{new MinMaxFilter("0", "12")});
          YearEditText.setFilters(new InputFilter[]{new MinMaxFilter("0", "2030")});
          StartingHourEditText.setFilters(new InputFilter[]{new MinMaxFilter("0", "24")});
          StartingMinuteEditText.setFilters(new InputFilter[]{new MinMaxFilter("0", "59")});
          EndingHourEditText.setFilters(new InputFilter[]{new MinMaxFilter("0", "24")});
          EndingMinuteEditText.setFilters(new InputFilter[]{new MinMaxFilter("0", "59")});
          //Step 2: get data into variables
  
          //Step 2.B: get data and assign
          //PROBLEM: If we just extract, the code won't be run because there's nothing to extract yet. We need a conditional.
          //SOLUTION: Create a condition for pressing the button, and then extract the variables when the button is pressed.
  
          TextWatcher dayTextWatcher = new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
                  day = Integer.parseInt(DayEditText.getText().toString());
              }
          };
          TextWatcher monthTextWatcher = new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
                  month = Integer.parseInt(MonthEditText.getText().toString());
              }
          };
          TextWatcher yearTextWatcher = new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
                  year = Integer.parseInt(YearEditText.getText().toString());
              }
          };
          TextWatcher titleTextWatcher = new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
                  title = Title.getText().toString();
              }
          };
          TextWatcher s_hourTextWatcher = new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
                  s_hour = Integer.parseInt(StartingHourEditText.getText().toString());
              }
          };
          TextWatcher s_minTextWatcher = new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
                  s_min = Integer.parseInt(StartingMinuteEditText.getText().toString());
              }
          };
          TextWatcher e_minTextWatcher = new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
                  e_min = Integer.parseInt(EndingMinuteEditText.getText().toString());
              }
          };
          TextWatcher e_hourTextWatcher = new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
                  e_hour = Integer.parseInt(EndingHourEditText.getText().toString());
              }
          };
  
          DayEditText.addTextChangedListener(dayTextWatcher);
          MonthEditText.addTextChangedListener(monthTextWatcher);
          YearEditText.addTextChangedListener(yearTextWatcher);
          Title.addTextChangedListener(titleTextWatcher);
          StartingMinuteEditText.addTextChangedListener(s_minTextWatcher);
          StartingHourEditText.addTextChangedListener(s_hourTextWatcher);
          EndingMinuteEditText.addTextChangedListener(e_minTextWatcher);
          EndingHourEditText.addTextChangedListener(e_hourTextWatcher);
  
          NewEventButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  answer1.clearCheck();
                  Intent agendaPageGoing = new Intent(getApplicationContext(), AgendaActivity.class);
                  startActivity(agendaPageGoing);
  
                  //HERE IS WHERE IT SHOULD GO
              }
          });
  
  
  
      }
  }
  </code></pre>
  
  <p>PS: the app is a calendar. After going through all the code, I need some variables and to get to Agenda. Also, the fields should be cleared.</p>