1

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!

5 Answers 5

3

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

hope this will help you.

2

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("");
    }
1

Why not use edittext.setText("");

Or alternatively you could use edittext.setText(null)

0

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("");

}
0

manually clear all the editText using this in onResume

edtText.setText("");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.