EditText onClick not shows Virtual Keyboard

元气小坏坏 提交于 2019-11-30 20:57:54
Sergio Andreotti

Try with this, it worked for me.

EditText etHorseName = (EditText) getView().findViewById(R.id.horseName);
etHorseName.clearFocus();

in onCreate() or where you want.

Late answer but here is how to solve it without adding code, just remove this from your XML:

<requestFocus />

No idea why the keyboard does not show up when this is set... It does show up however if you first loose the focus and then click on the edit text. I had the problem on Android 2.3.6 but it worked on 4.1.2, so maybe it was an early bug.

AAnkit

It is just a default behavior , you not suppose to do it manually, remove below part from your code.

titleEdit.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {

        InputMethodManager imm = (InputMethodManager) CreateNote.this
                .getSystemService(Service.INPUT_METHOD_SERVICE);
        imm.showSoftInput(titleEdit, 0);
    }
});
anjaneya

Try to hide and show the keyboard with this code:

InputMethodManager imm = (InputMethodManager) this.getSystemService(Service.INPUT_METHOD_SERVICE);
// To show keyboard
imm.showSoftInput(titleEdit, 0);
// To hide keyboard
imm.hideSoftInputFromWindow(titleEdit.getWindowToken(), 0);  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!