按钮可显示虚拟键盘?按钮、键盘

2023-09-04 13:39:52 作者:捧着风的少女

我有一个ListView并且可以使用硬件键盘过滤出的项目。不过我应该做的手机,没有硬件键盘,只有一个虚拟的?有没有一种方法来添加一个按钮,当pressed,虚拟键盘显示出来?

I have a ListView and it is possible to use the hardware keyboard to filter out items. However what should I do for phones that don't have a hardware keyboard and only a virtual one? Is there a way to add a button that when pressed, the virtual keyboard shows up?

推荐答案

我可以切换屏幕上的键盘使用下面的code。我希望这是有用的人。

I was able to toggle the on-screen keyboard using the code below. I hope this is useful to someone.

InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);