Search code examples
androidsearchview

SearchView with OneClick to enter text


In the android default search view, 2 clicks are required to input text for search as the first click is used to expand the editText view and another click is to set focus.

It seems to be q redundant and i want to reduce the process to one click only. Is there any methods to do this?


Solution

  • The two clicks happen if we put the searchView inside a ListView as the searchView lost focus after that. I suspect searchView behave a similar property with editText view in listView.

    With reference to Edit Text in ListActivity ListView loses focus when keyboard comes up

    and add the following codes in searchView xml android:focusable="true" android:focusableInTouchMode="true"

    would get back the normal behavior of the searchView. Hope this will be useful to other people in the future.