Android Hide Soft Keyboard from EditText while not losing cursor

前端 未结 14 1923
日久生厌
日久生厌 2020-12-03 04:55

I\'ve come about as far as this which gets me halfway there, but not quite. I have a dialer Fragment that has all the usual Buttons to enter a numb

14条回答
  •  天命终不由人
    2020-12-03 05:38

    Setting the flag textIsSelectable to true disables the soft keyboard.

    You can set it in your xml layout like this:

    
    

    Or programmatically, like this:

    EditText editText = (EditText) findViewById(R.id.editText);
    editText.setTextIsSelectable(true);
    

    The cursor will still be present, you'll be able to select/copy/cut/paste but the soft keyboard will never show.

提交回复
热议问题