0

I want to my phone to show numeric keyboard when I focus on an EditText which is set to InputType.TYPE_NUMBER_FLAG_DECIMAL. But it shows alphanumeric (normal keyboard like whatsapp's) keyboard, How can I achieve this?

I use this to open keyboard:

InputMethodManager inputMethodManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

I use this to set input type of EditText:

mEditText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);

It's Dynamic. So I can't write it as XML attribute. User can switch input type with these two lines:
mEditText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); to get a floating number between 0 and 2.
mEditText.setInputType(InputType.TYPE_CLASS_NUMBER); to get any integer bigger or equal than 0.

Thanks in advance..

Muhammed Aydogan
  • 570
  • 1
  • 4
  • 22

1 Answers1

1

It is better to set inputType in XML code