Clear edittext focus and hide keyboard when button is pressed

前端 未结 4 2161
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 06:04

I\'m making an app with edittext and a button. When I enter something into edittext and then click a button, I want the keyboard and focus on edittext to disappear but I can\'t

4条回答
  •  情话喂你
    2021-02-10 06:31

    another solution is, create a dummy layout

    
    
    

    and set the focus in your onButtonClickFunction

    ((LinearLayout) findViewById(R.id.dummy_id)).requestFocus();
    

提交回复
热议问题