Reputation: 355
I have a little problem. 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.
(I don't need in XML)
The primary error is 'Android.Widget.EditText' does not contain a definition for 'setMaxLength/setFilters' and no extension method 'setMaxLength/setFilters' accepting a first argument of type 'Android.Widget.EditText' could be found (are you missing a using directive or an assembly reference)
Metion that I use Xamarin. Thank you in advance.
Upvotes: 0
Views: 443
Reputation: 24470
Did you even explore which methods and properties are ACTUALLY available to you on the instance of EditText
?
Method names in C# are generally start with a capital letter so simply fixing that and actually using a filter that exists helps a lot.
editText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(10) });
That for instance compiles just fine...
Next time please explore the available values and methods through the intellisense available to you in the IDE, it can actually be useful. Just blindly copying some Java code into your app will rarely work.
Upvotes: 2