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

     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);
        }
    }

猜你喜欢

转载自blog.csdn.net/github_37610197/article/details/78689647
今日推荐