Is there a way to remove the Toast " password did not match" if I stop typing or deleting the typed words?

27 views Asked by At
     conPass.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                System.out.println(s.toString());
                String password = pass.getText().toString();
                String confirmPass = conPass.getText().toString();
                if (!TextUtils.isEmpty(password) && !TextUtils.isEmpty(confirmPass)) {
                    if (password.equals(confirmPass)) {
                        Toast.makeText(MainActivity.this, "Password match", Toast.LENGTH_SHORT).show();
                    }

What code should I use so that I don't get the error if I stop typing the toast message will pop up?

                else{
                        Toast.makeText(MainActivity.this, "Password did not match", Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });
    }
}
0

There are 0 answers