AutoCompleteTextView与普通防爆pressio

AutoCompleteTextView与普通防爆pressio

本文介绍了Android的AutoCompleteTextView与普通防爆pression?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

小白在这里机器人,从iOS的,在这之前的.Net来之前这一切,C和Fortran的方式。

noob to Android here, coming from iOS, .Net before that, C and Fortran way before all that.

如果我有一些1000+字符串就可以了,我怎么可能修改AutoCompleteTextView(或MultiAutoCompleteTextView或任何派生类),这样我可以修改字符串匹配标准与常规的前pression的ArrayAdapter。

If I have an ArrayAdapter with some 1000+ string on it, how could I modify an AutoCompleteTextView (or MultiAutoCompleteTextView or any derived Class) so that I can modify the match criteria of the strings with a regular expression.

这是容易理解的短的例子:

It's easier to understand with a short example:

ArrayAdapter的典型内容:

Typical content of ArrayAdapter:

W 20 x 100
W 16 x 89    -> 1
W 16 x 15    -> 2
WT 8 x 44
C 9

我想忽略无论是与否的用户使用空格或/和小写的x,以present可能的匹配,

I want to ignore whether the or not the user uses spaces OR / AND lowercase 'x' to present a list of possible matches'

因此​​,如果用户键入W¯¯16倍 W16 X W16 两个 - →1 - > 2 将显示自动完成建议列表上

So if the user types W 16x or W16 x or w16 both ->1 and ->2 will show up on the autocomplete suggestion list.

推荐答案

既然你是一个codeR我去给你在正确的道路......这不是写你的榜样,而是一个正则表达式中的Java / Android的普通的例子。

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

这篇关于Android的AutoCompleteTextView与普通防爆pression?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 17:14