Android Hide Soft Keyboard from EditText while not losing cursor

前端 未结 14 1907
日久生厌
日久生厌 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:48
        EditText text = (EditText) findViewById(R.id.text);
        if (Build.VERSION.SDK_INT >= 11) {
            text.setRawInputType(InputType.TYPE_CLASS_TEXT);
            text.setTextIsSelectable(true);
        } else {
            text.setRawInputType(InputType.TYPE_NULL);
            text.setFocusable(true);
        }
    
    0 讨论(0)
  • 2020-12-03 05:48

    You can use the following line of code in the activity's onCreate method to make sure the keyboard only pops up when a user clicks or touch into an EditText Field. I tried lots of methods and codes from stackoverflow but didnt work any but this Works Perfectly for me!! Try this.. :)`

     this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    
    0 讨论(0)
提交回复
热议问题