1
Android 전문가가 입력 필터를 사용하여 문자 -
을 무시할 수 있습니까? 나는 사용자가 제외하고는 아무 것도 입력 할 싶습니다android가 특수 문자 입력을 무시합니다.
나는이 작업을 수행하는 클래스를 설정하지만, 모든 문자는 당신의 도움이 코멘트 ..... StoneBird에
public class InputFilterReservedCharacters implements InputFilter {
@Override
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
try {
if (end > start) {
for (int index = start; index < end; index++) {
if (source.charAt(index) == "-".toCharArray()[0]) {
return "";
}
}
}
} catch (NumberFormatException nfe) {
}
return "";
}
}
감사를 무시하는 ' - '. 함수가 -
다음 함수가 결과로 ""
를 반환합니다 발견하면 if (source.charAt(index) == "-".toCharArray()[0]) {return "";}
의미
@Override
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
String returnValue = "";
try {
if (end > start) {
for (int index = start; index < end; index++) {
if (source.charAt(index) != '-'){
returnValue = Character.toString(source.charAt(index));
}
}
}
} catch (NumberFormatException nfe) {
}
return returnValue;
}
ignore로하면 문자열에서 '-'을 제거하겠습니까? – wtsang02