How to prevent virtual keyboard displaying when long-press on EditText Widget?

前端 未结 2 894
灰色年华
灰色年华 2021-01-06 22:29

I\'ve got an EditText widget in my app which I have set to read-only, and I want to know when the user long-presses on it. I don\'t want the virtual keyboard to popup if the

2条回答
  •  半阙折子戏
    2021-01-06 23:25

    Try using this and options available.

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    

    My problem was that when ever my activity started, kepyboard poped up automatically if there is an EditText. So, I used the above in OnCreate(). Try using different options instead of ".SOFT_INPUT_STATE_ALWAYS_HIDDEN"

提交回复
热议问题