How to Open Android Soft Keyboard (Numeric) Programmatically ?

3.3k Views Asked by At

I know how to open a soft keyboard and even handle its key events. I need to open Numeric keyboard.

P.S I am not using Edittexts in layout file.

Here is the code I am using to open keyboard programmatically

    if (PasscodeLockUpdated.this != null) {
    PasscodeLockUpdated.this .getWindow()
    .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);}
1

There are 1 best solutions below

3
On

Are you adding an EditText programmatically? If so, you can change the InputType (as you would if you had xml) in java using:

yourEditText.setInputType(InputType.TYPE_CLASS_NUMBER | **Another type if you want more than one**);

Hope that helps.