Show the softkeyboard with only alphanumeric keys?

匆匆过客 提交于 2019-12-10 17:10:37

问题


Is it possible?

I would like to show the keyboard with the bare basic alphabetic and numeric buttons, no settings key or smiley key or anything like that, just the letters, numbers, space, done, and shift etc.

I swear I happened to catch an article about how to set the keyboard in this mode months ago, but I can't find it now!

I looked at the possible values for android:inputType & android:windowSoftInputMode but I can't see anything that would help. What am I missing?

Update

The software is designed to run on a particular tablet, one that the customers purchase with the software and we control what is installed on it. They currently run Cyanogen 4.2.2 with the standard keyboard.


回答1:


I think, the only way to achieve what you want it's to create a Custom SoftKeyboard with a custom KeyboardView class.
Here is a tutorial: Custom keyboard and see this SO question: Android app specific soft keyboard especially this answer which links to a open source project.




回答2:


Did you give a try to android:inputType="textVisiblePassword".

It will show something like this:




回答3:


Well there is no general solution for that, you have to remember there is no universal keyboard and even if there were people can just download a different keyboard app from the Play Store. Samsung, HTC, Nexus, all have there own keyboard and many oem even have different ones for different phones.

So aside from setting:

android:inputType="number"

on your EditText's there is nothing you can do. Every keyboard handles this in there own way.

EDIT:

If you control which software is installed than you can write a custom keyboard app or search for a keyboard app which supports the feature you need and which you can ship with your tablet. But aside from that there is nothing you can do.

EDIT 2:

Here is a link to a tutorial which explains how to write a custom keyboard: link

EDIT 3:

You always have the option of just emulating the keyboard. Place a fragment containing the buttons you need at the bottom of the screen with visibility View.GONE and set it to View.VISIBLE when the user needs it. You can prevent the normal keyboard from appearing with this code:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

I actually did something like that for an app I wrote a few months ago. When you apply a fade & translation animation to the fragment as you set it to View.VISIBLE it actually looks pretty good!



来源:https://stackoverflow.com/questions/22563088/show-the-softkeyboard-with-only-alphanumeric-keys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!