</resources>
显示错误信息
/** * 显示错误信息 * * @param c * @param editText * @param str */ public static void showEditTextError(Context c, EditText editText, int str) { Selection.selectAll(editText.getText()); editText.setError(c.getResources().getString(str)); editText.requestFocus(); InputMethodManager imm = (InputMethodManager) c .getSystemService(Context.INPUT_METHOD_SERVICE); View view = ((Activity) c).getCurrentFocus(); if (view != null) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0);// 隐藏软键盘 } } /** * 显示错误信息 * * @param c * @param editText * @param str */ public static void showAutoCompleteTextViewError(Context c, AutoCompleteTextView editText, int str) { Selection.selectAll(editText.getText()); editText.setError(c.getResources().getString(str)); editText.requestFocus(); InputMethodManager imm = (InputMethodManager) c .getSystemService(Context.INPUT_METHOD_SERVICE); View view = ((Activity) c).getCurrentFocus(); if (view != null) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0);// 隐藏软键盘 } }