我正在使用edittext和一个按钮创建一个应用程序.当我在edittext中输入内容然后单击一个按钮时,我想要键盘并专注于edittext消失,但我似乎无法做到.
我在XML中插入了这两行代码:
android:focusable="true"
android:focusableInTouchMode="true"
Run Code Online (Sandbox Code Playgroud)
我还尝试在按钮单击方法中添加它:
edittext.clearFocus();
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Run Code Online (Sandbox Code Playgroud)
它只是不起作用,按下按钮后,键盘仍然在那里,edittext仍然有焦点.