Question

I am building an application where I want to show only numbers keypad i.e 0,1,2,3,4,5,6,7,8,9 digits dynamically.That number keypad is being used for the field name 'phone number'. I have the solution but that works in a static way..but my phone field is dynamic,now I am using

phoneText.setKeyListener(new DigitsKeyListener(true, true));

method,but this method shows total numeric soft keypad..and I want only numbers to be displayed..

Was it helpful?

Solution

Have you tried?

phoneText.setInputType(InputType.TYPE_CLASS_PHONE);

OTHER TIPS

use this..

android:inputType="phone" 

for dynamic

    EditText et = new EditText(this);
 et.setInputType(InputType.TYPE_CLASS_PHONE);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top