简体   繁体   English

软键盘不会出现

[英]Soft keyboard won't appear

Hello I want to show up the soft keyboard whenever I tap on the textfield. 你好,我想在我点击文本字段时显示软键盘。 the application of mine works fine whenever u login for the first time but when i logout from the application it does not pop up. 我第一次登录时,我的应用程序工作正常但是当我从应用程序注销时它没有弹出。

You can show the soft keyboard focused on a specific EditText like this. 您可以显示专注于特定EditText的软键盘。

EditText editText = (EditText) findViewById(R.id.edit);
InputMethodManager imm = (InputMethodManager) getSystemService(
    Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

I have ran into this many a time. 我遇到过这么多次。 Please resist to force the keyboard to show. 请拒绝强制键盘显示。 Any device that has a physical hard keyboard will not show in many different kinds of views. 任何具有物理硬键盘的设备都不会在许多不同类型的视图中显示。 Try running your application on a devices that are not connected to a bluetooth keyboard and does not have a hard keyboard. 尝试在未连接蓝牙键盘且没有硬键盘的设备上运行应用程序。

EditText should handle this for you, post some of your code and maybe we can help figure out why it is not doing so. EditText应该为您处理这个问题,发布一些代码,也许我们可以帮助弄清楚它为什么不这样做。 Or you can force the soft keyboard to show by doing something like this: 或者您可以通过执行以下操作强制软键盘显示:

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

If you put that inside the onClick() method for an OnClickListener that you set on your EditText then it will force the keyboard open whenever the EditText is clicked. 如果你把它放在你在EditText上设置的OnClickListener的onClick()方法中,那么只要单击EditText,它就会强制打开键盘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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