I was trying to set the max length of an EditText, but I didn't get success.
I tried like this:
a.setFilters (new InputFilter[] { new InputFilter.LengthFilter (a.Length) });
and I get some errors ( Not at a.Length ).
and like this:
a.setMaxLength ( a.Lenght);
and still some errors.
I think that I forget some headers but that's just a guess.
Metion that I use Xamarin. Thank you in advance.
setFilters(new InputFilter[]{ new InputFilterMinMax("1", "12")}); This will allow user to enter values from 1 to 12 only.
If you using c# best if you try it like this
MyEditText.SetFilters( new IInputFilter[] { new InputFilterLengthFilter(10) } );
Try
TextView a = new TextView(...);
InputFilter[] filter = new InputFilter[1];
filter[1] = new InputFilter.LengthFilter(10);
a.setFilters (filter);
or Use this in your xml:
android:maxLength="20"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With