Android AutoCompleteTextView with Regular Expression?

空扰寡人 提交于 2019-12-01 21:01:36

Since you're a coder I'll get you on the right path ... this isn't written to your example, but rather a general example of RegEx in Java/Android.

protected ArrayList<String> splitMsg(SmsMessage smsMessage) {
        ArrayList<String> smt;
        Pattern p = Pattern.compile(".{1,160}");
        Matcher regexMatcher = p.matcher(smsMessage.getMsgBody());
        smt = new ArrayList<String>();
        while (regexMatcher.find()) {
            smt.add(regexMatcher.group());
        }
        return smt;
    }

There's no validation so you'll have to implement:

smsMsgBody_editText.addTextChangedListener(new TextWatcher() {
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        /*
         * Do something fancy like regex match ;)
        */
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!