c# - Check EditText for character count -
i writing android app via xamarin (c#)
i have edittext field. , have check nullorempty.
if (string.isnullorempty (ulitsa.text) ) { toast.maketext (this, "Заполните поле 'Ваша Улица'", toastlength.long).show (); }
i want set max , min character filters. min-3, max-6 ,and if user don't have count of characters show toast notification.
how can realize this?
myedittext.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence s, int start, int before, int count) { // todo auto-generated method stub } @override public void beforetextchanged(charsequence s, int start, int count, int after) { // todo auto-generated method stub } @override public void aftertextchanged(editable s) { //here, text length: integer len = myedittext.gettext().tostring().length(); // then, depending on length display toast , want } });
but can set max length programmatically:
inputfilter[] filterarray = new inputfilter[1]; filterarray[0] = new inputfilter.lengthfilter(6); myedittext.setfilters(filterarray);
Comments
Post a Comment