Antoine Murion
Antoine Murion

Reputation: 813

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?

Upvotes: 0

Views: 358

Answers (2)

scottD
scottD

Reputation: 135

You can change this behavior by calling

setIconifiedByDefault(false)

on your searchView. Setting it to false will show the whole field.

Documentation here.

Upvotes: 1

Antoine Murion
Antoine Murion

Reputation: 813

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.

Upvotes: 0

Related Questions