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:
inside et.setText("");
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("");