I want to remove focus and text from SearchView
in onResume()
.
I tried searchView.clearFocus()
but it is not working.
Thi
I want to remove focus and text from
SearchView
inonResume()
To achieve this you could set your root layout focusable with the android:focusableInTouchMode
attribute and request focus on that View
in onResume()
.
For example:
And then in your Activity
:
private View rootView;
private SearchView searchView;
// ...
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
rootView = findViewById(R.id.root_layout);
searchView = (SearchView) findViewById(R.id.search_view);
}
@Override
protected void onResume() {
super.onResume();
searchView.setQuery("", false);
rootView.requestFocus();
}