EditText return back previously input data after p

2019-08-15 02:47发布

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条回答
Summer. ? 凉城
2楼-- · 2019-08-15 02:59

manually clear all the editText using this in onResume

edtText.setText("");
查看更多
冷血范
3楼-- · 2019-08-15 03:02

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

}
查看更多
The star\"
4楼-- · 2019-08-15 03:07

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

hope this will help you.

查看更多
Juvenile、少年°
5楼-- · 2019-08-15 03:07

Why not use edittext.setText("");

Or alternatively you could use edittext.setText(null)

查看更多
我想做一个坏孩纸
6楼-- · 2019-08-15 03:10

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("");
    }
查看更多
登录 后发表回答