Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android set specific characters as inputType

Tags:

android

I'm looking for a way to "customize" the inputType of a EditText. The user should enter a date which has the format dd.mm.yyyy (and yes, I don't want to use a date picker). Setting the inputType to numberDecimal allows entering only one point, but I would like to have only the numeric keyboard, not the whole one. Is there an easy way reaching that without writing a custom keyboard?

So basically I just want to use [1,2,3,4,5,6,7,8,9,0,.]

like image 217
Valentino Ru Avatar asked Mar 26 '26 14:03

Valentino Ru


1 Answers

Whenever you limit the input to a unique set of characters you can use the digits attribute:

android:digits="01234567890./-"

Every characters you specify can be used one or more times, you can even include letters and other symbols.

like image 51
Sam Avatar answered Mar 29 '26 12:03

Sam