-1

how would I get the same effect of having a phone keyboard with only digits which I would get using these xml attributes

android:inputType="phone"
android:digits="0123456789"

using Java and setInput or setRawInput?

reactor
  • 1,722
  • 1
  • 14
  • 34

1 Answers1

1

Try programmatically like below:

editText.setInputType(InputType.TYPE_CLASS_PHONE);
editText.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
Md. Asaduzzaman
  • 14,963
  • 2
  • 34
  • 46