How to add multiple inputType in TextField Jetpack Compose

948 views Asked by At

I have one TextField using Jetpack Compose. In that field, I want only Number and Text input. I can apply to only one property at the same time. Like below,

TextField(
    keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text)

How can I add Text and Number input types?

1

There are 1 answers

5
Abhimanyu On

Code

keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text)

How can I add Text and Number input types?

The type mentioned is to specify keyboard type as the parameter name implies keyboardType.
You can't show two keyboards at once.
So multiple keyboard types have no meaning.


From your question, I am guessing you want to show the soft keyboard which has both letters and numbers. (Comment below if that is not the case)

Use KeyboardType.Password for that.

KeyboardType.Password

Extras.

KeyboardType.Text.
KeyboardType.Text

KeyboardType.Number.
KeyboardType.Number

KeyboardType.NumberPassword.
KeyboardType.NumberPassword