noob to Android here, coming from iOS, .Net before that, C and Fortran way before all that.
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:
Typical content of ArrayAdapter:
W 20 x 100
W 16 x 89 -> 1
W 16 x 15 -> 2
WT 8 x 44
C 9
I want to ignore whether the or not the user uses spaces OR / AND lowercase 'x' to present a list of possible matches'
So if the user types开发者_运维技巧 W 16x
or W16 x
or w16
both ->1
and ->2
will show up on the autocomplete suggestion list.
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 ;)
*/
}
});
精彩评论