Android Open Source - ExpertAndroid Password Field Rule

From Project

Back to project page ExpertAndroid.


The source code is released under:

MIT License

If you think the Android project ExpertAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.iuriio.demos.expertandroid.ch6forms;
/*from ww  w . j a va2  s . c  o m*/
import android.widget.EditText;
import android.widget.TextView;

 * Created by iuriio on 10/24/13.
public class PasswordFieldRule implements IValidator {
    private TextView password1;
    private TextView password2;

    public PasswordFieldRule(TextView password1, TextView password2) {
        this.password1 = password1;
        this.password2 = password2;

    public boolean validate() {
        String p1 = this.password1.getText().toString();
        String p2 = this.password2.getText().toString();
        if (p1.equals(p2)) {
            return true;

        this.password2.setError("Sorry, password values don't match!");
        return false;

Java Source Code List