Android examples for android.text:InputFilter
create Numeric Input Filter
//package com.java2s; import android.text.InputFilter; import android.text.Spanned; public class Main { public static InputFilter[] createNumericInputFilter() { InputFilter inputFilter = new InputFilter() { @Override/*from w w w .ja v a 2 s .co m*/ public CharSequence filter(CharSequence source, // int start, int end, Spanned dest, int dstart, int dend) { if (source.toString().matches("^[0-9]+$")) { return source; } else { return ""; } } }; return new InputFilter[] { inputFilter }; } }