Android examples for User Interface:EditText
is EditText Empty Error
//package com.java2s; import android.content.Context; import android.support.annotation.StringRes; import android.text.TextUtils; import android.widget.EditText; public class Main { public static boolean isEditTextEmptyError(Context context, EditText editText, CharSequence sequence, @StringRes int errorRes) { if (editText == null) { throw new NullPointerException("editText is Null"); }// ww w . ja v a 2 s. c om if (TextUtils.isEmpty(sequence)) { editText.setError(context.getString(errorRes)); return true; } editText.setError(null); return false; } }