Blackberry Text Filter

旧街凉风 提交于 2019-12-13 02:46:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!