判断EditText字体超出限制,或者为空并提示

来源:互联网 发布:effective java 知乎 编辑:程序博客网 时间:2024/05/19 05:32
     String txt = StrUtils.checkEditString(edit_speak_content,  getResources().getString(R.string.note_edit_text_non_tips));                StrUtils.checkString(txt.length() <= 500,  getResources().getString(R.string.note_edit_text_tips));

StrUtils类

    public static String checkEditString(TextView editText, String msg4Null) throws InputNullException {        String input = editText.getText().toString();        if (TextUtils.isEmpty(input)) {//            throw new InputNullException("editText input is Null");            throw new InputNullException(msg4Null);        }        return input;    }    public static void checkString(boolean flag, String msg4Null) throws InputNullException {        if (!flag) {            throw new InputNullException(msg4Null);        }    }
原创粉丝点击