How to set focus on a view when a layout is created and displayed?

后端 未结 15 1239
Happy的楠姐
Happy的楠姐 2020-12-02 15:07

Currently, I have a layout which contains a Button, a TextView and an EditText. When the layout is displayed, the focus will be automa

15条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 15:33

    You can try just hidding the keyboard. Something like this:

    InputMethodManager inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    

提交回复
热议问题