EditText onClick not shows Virtual Keyboard

后端 未结 4 1281

If i click on my EditText, the virtual keyboard simple not shows up. The cursor is shown, but no keyboard to type on.

I even tried it with manually open but just no

相关标签:
4条回答
  • 2021-01-05 19:16

    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);  
    
    0 讨论(0)
  • 2021-01-05 19:19

    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.

    0 讨论(0)
  • 2021-01-05 19:30

    Try with this, it worked for me.

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

    in onCreate() or where you want.

    0 讨论(0)
  • 2021-01-05 19:32

    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);
        }
    });
    
    0 讨论(0)
提交回复
热议问题