Soft keyboard won't appear

試著忘記壹切 提交于 2020-01-25 19:24:27

问题


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.


回答1:


You can show the soft keyboard focused on a specific EditText like this.

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



回答2:


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.




回答3:


EditText should handle this for you, post some of your code and maybe we can help figure out why it is not doing so. 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.



来源:https://stackoverflow.com/questions/5340137/soft-keyboard-wont-appear

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