简体   繁体   中英

How to Open Android Soft Keyboard (Numeric) Programmatically ?

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

PS 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);}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM