Android searchView not in action Bar remove focus

OK, this question has been asked many times, and I looked through a lot of topics about it, but I can't get it to work.

My searchView not in actionBar, so I cannot use collapseActionView()

I tried

 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 

No matter what I try, I cannot remove focus from the searchView after selecting it

+5
source share
1 answer

To clear focus from my searchView after completing my request, I first had to add

  android:focusable="true" android:focusableInTouchMode="true" 

for my parent activity layout. Then in action

  LinearLayout myLayout = (LinearLayout) activity.findViewById(R.id.my_layout); myLayout.requestFocus(); 

This will divert attention from the searchView. All the information I needed was here. How to remove focus without setting focus to another control?

+9
source

All Articles