如果输入的信息不符合要求,如何停止进度条?

时间:2017-04-22 06:34:29

标签: android progressdialog android-progressbar

我有一个基本的用户注册页面,用户通过输入用户名和密码进行注册。如果密码短于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();`

1 个答案:

答案 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.
}`