check Require EditText Fields - Android java.lang.reflect

Android examples for java.lang.reflect:Field

Description

check Require EditText Fields

Demo Code


//package com.java2s;
import android.widget.EditText;

public class Main {
    public static boolean checkRequireFields(String requiredMessage,
            EditText... editTexts) {//from   w  w  w.ja  v a2 s  .co m

        boolean hasRequired = false;

        for (EditText editText : editTexts) {
            String textValue = editText.getText().toString();
            if (textValue.trim().isEmpty()) {
                editText.setError(requiredMessage);
                hasRequired = true;
            }
        }
        return hasRequired;
    }
}

Related Tutorials