user1230268
user1230268

Reputation: 221

what ist the equivalent to Edittext.Setinputtype in Xamarin

In my Xamarin Android app I want to change the InputType of a Edititext in code.

But the Xamarin EditText has no setInputType method.

I tried:

  public void spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
    {
        Spinner spinner = (Spinner)sender;

        sf = spinner.GetItemAtPosition(e.Position).ToString();
        if (sf == "kdnr" || sf == "plz")    // those field are numeric
        { _suchkun.InputType = Android.Text.InputTypes.ClassNumber; }
        else
        { _suchkun.InputType = Android.Text.InputTypes.ClassText; }

    }

but without succes.

Upvotes: 2

Views: 1894

Answers (1)

Cheesebaron
Cheesebaron

Reputation: 24460

I've made an answer here, which demonstrates switching InputType on the fly while typing.

Basically you are doing it correct, you simply assign a value to the InputType property, which is the equivalent of using setInputType in Java Android.

_suchkun.InputType = InputTypes.ClassNumber;

That is all you should need to do.

Upvotes: 4

Related Questions