Or better yet, is there a method in Xamarin.Forms that'll set it for me?
Here's what I have so far, but I know I'm way off, and don't support KeyboardFlags
, which I'd like to be able to.
Droid
private void SetKeyboard()
{
if (Element.Keyboard == Keyboard.Url)
{
NativeView.EditText.InputType = InputTypes.ClassText | InputTypes.TextVariationUri;
}
else if (Element.Keyboard == Keyboard.Email)
{
NativeView.EditText.InputType = InputTypes.ClassText | InputTypes.TextVariationEmailAddress;
}
else if (Element.Keyboard == Keyboard.Numeric)
{
NativeView.EditText.InputType = InputTypes.ClassNumber;
}
else if (Element.Keyboard == Keyboard.Chat)
{
NativeView.EditText.InputType = InputTypes.ClassText | InputTypes.TextVariationShortMessage;
}
else if (Element.Keyboard == Keyboard.Telephone)
{
NativeView.EditText.InputType = InputTypes.ClassPhone;
}
else if (Element.Keyboard == Keyboard.Text)
{
NativeView.EditText.InputType = InputTypes.ClassText | InputTypes.TextFlagNoSuggestions;
}
}
Touch
private void SetKeyboard()
{
if (Element.Keyboard == Keyboard.Chat)
{
NativeView.KeyboardType = UIKeyboardType.Twitter;
}
else if (Element.Keyboard == Keyboard.Text)
{
NativeView.KeyboardType = UIKeyboardType.ASCIICapable;
}
else if (Element.Keyboard == Keyboard.Numeric)
{
NativeView.KeyboardType = UIKeyboardType.NumberPad;
}
else if (Element.Keyboard == Keyboard.Telephone)
{
NativeView.KeyboardType = UIKeyboardType.PhonePad;
}
else if (Element.Keyboard == Keyboard.Url)
{
NativeView.KeyboardType = UIKeyboardType.Url;
}
else if (Element.Keyboard == Keyboard.Email)
{
NativeView.KeyboardType = UIKeyboardType.EmailAddress;
}
}