Restrict Edittext input content using Input Filters in ANDROID

Posted by Unknown Jumat, 22 Maret 2013 0 komentar

InputFilter filter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
// TODO Auto-generated method stub
for (int i = start; i < end; i++) {
if (Character.isLetter(source.charAt(i))) {
System.out.println("Input consist of only characters from 'a' to 'z'");
return "";
}
}
return null;
} };
edit.setFilters(new InputFilter[]{filter});
Here the filters will check whether the input content has only characters from 'a' to 'z'.
same way use the condition below to have characters from'a' to 'z' and '0' to '9' and avoid special characters.

Character.isLetterOrDigit(source.charAt(i))

TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: Restrict Edittext input content using Input Filters in ANDROID
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://androidpopuler.blogspot.com/2013/03/restrict-edittext-input-content-using.html. Terima kasih sudah singgah membaca artikel ini.

0 komentar:

Posting Komentar

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.