Goo*_*ner 6 android searchview
好的,这个问题已被多次询问,我已经查看了很多关于它的主题,但我无法让它工作.
我searchView不在动作栏上,所以我不能使用collapseActionView()
我试过了
searchView.clearFocus();//this closes the keyboard but does not remove focus
getActivity().getCurrentFocus().clearFocus(); //basically the same as above
searchView.setQuery("", false); //this clears the query and drops the keyboard
searchView.setIconified(true); // but the search retains focus and keyboard pops up again
Run Code Online (Sandbox Code Playgroud)
无论我尝试什么,我都无法从选择searchView之后移除焦点
Goo*_*ner 10
要在执行我的查询后从searchView清除焦点,我首先要添加
android:focusable="true"
android:focusableInTouchMode="true"
Run Code Online (Sandbox Code Playgroud)
到我的父活动布局.然后在活动中
LinearLayout myLayout = (LinearLayout) activity.findViewById(R.id.my_layout);
myLayout.requestFocus();
Run Code Online (Sandbox Code Playgroud)
这将使焦点远离searchView.我需要的所有信息都在这里如何在不将焦点设置到另一个控件的情况下移除焦点?
| 归档时间: |
|
| 查看次数: |
4767 次 |
| 最近记录: |