EditText return back previously input data after p

2019-08-15 02:52发布

问题:

I have an application login system type of application. Once the user pressed back button after login, the username and password EditText are filled with what the user enter just now. Is there any way to clear the EditText to empty? Sorry that if I make this sounds confusing. Any comment will be appreciated!

回答1:

you can do this by overriding onPause method of Activity and in onPause method clear all EditText Value as:

@Override
 protected void onPause(){
        super.onPause();

         // Clear all value here
        editTextone.setText("");
        editTexttwo.setText("");
    }


回答2:

et.setText(""); inside onResume() to set empty text on immediate start.

hope this will help you.



回答3:

Why not use edittext.setText("");

Or alternatively you could use edittext.setText(null)



回答4:

Guess this will solve your problem.

@Override
public void onResume(){
    super.onResume();

    EditText username = (EditText) findViewById(R.id.edittext);
    username.setText("");
    EditText password = (EditText) findViewById(R.id.edittext);
    password.setText("");

}


回答5:

manually clear all the editText using this in onResume

edtText.setText("");