EditText return back previously input data after pressed back button

倖福魔咒の 提交于 2019-12-13 01:34:39

问题


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


来源:https://stackoverflow.com/questions/14119158/edittext-return-back-previously-input-data-after-pressed-back-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!