我有一个基本的用户注册页面,用户通过输入用户名和密码进行注册。如果密码短于6个字符,则提交不应该通过并显示Toast,但是在我的代码中,进度条会出现并且不会消失,我该如何解决?
if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) {
// mProgress.setMessage("Signing up...");
// mProgress.show();
if (password.length()<6){
Toast.makeText(VendorRegistration.this,"Passwords must contain at least 6 charachters",
Toast.LENGTH_LONG).show();
}
progress1.setMessage("Registering...");
progress1.show();`
答案 0 :(得分:0)
检查更正后的代码:
if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) {
if (password.length()<6){
Toast.makeText(VendorRegistration.this,"Passwords must contain at least 6 charachters",
Toast.LENGTH_LONG).show();
}else
{ progress1.setMessage("Registering...");
progress1.show();
// you can show progress only when all conditions become true.
}`