问题
I want a BasicEditField that lets me enter alphabets only...and a combination of upper case and lower case ...as in Jan, Feb...when i use the upper case and lower case filter that are there in BaiscEditField it allows either the entire string to be in upper case or lower case , not a combination.How do i achieve this?
回答1:
Richard's right, extend TextFilter, UPDATE according to Marc's suggestion:
class AlphaTextFilter extends TextFilter {
public char convert(char c, int status) {
if (!validate(c))
return 0;
return c;
}
public boolean validate(char c) {
return CharacterUtilities.isLetter(c);
}
}
Then simply use
BasicEditField.setFilter(new SimpleTextFilter());
See also BlackBerry Support Community Forums:Java Development:Input Text Validation
来源:https://stackoverflow.com/questions/1931475/blackberry-text-filter