简体   繁体   English

当用户导航到第二个屏幕到登录屏幕时,如何清除用户名和密码字段

[英]how to clear username & password field when user navigate to second screen to the login screen

I am making a app having login screen. 我正在制作一个有登录屏幕的应用程序。 My question is that if the user installed the application,then if for the first time user entered a username & password and click on login button then user navigate to second activity after that when user click on back button from second activity the username and password is still there in first activity. 我的问题是,如果用户安装了应用程序,那么如果用户第一次输入用户名和密码并单击登录按钮,那么用户导航到第二个活动,之后当用户点击第二个活动的后退按钮时,用户名和密码是仍然在第一次活动。 How can I clear the edittext field.Any help in this appreciated. 如何清除edittext字段。在此赞赏的任何帮助。

Just use 只是用

editText.setText("");

in your LoginActivity onResume() method. 在您的LoginActivity onResume()方法中。 Hope this helps. 希望这可以帮助。

Before starting the other activity(when user clicks on login button) you can set the text of both username and password edittext. 在开始其他活动之前(当用户单击登录按钮时),您可以设置用户名和密码edittext的文本。

username.setText("");
password.setText("");

why dont you use editTextUsername.setText(""); 为什么不使用editTextUsername.setText(""); And in your password flied it Automatical clear because you changed inputType to password. 并且在您的密码中,它自动清除,因为您将inputType更改为密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM