I have a EditText
, and I would like to restrict the number of characters which could be inputted in this EditText
, and make this
I would implement a filter:
InputFilter filter = new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
if (source.length > 10){
//cancel the edit or whatever
}
}
};
EditText editText = (EditText) findViewById(R.id.rg);
editText.setFilters(new InputFilter[] {filter});