Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show android SearchView EditText by default

I am using a SearchView in android. When I first land on the page, all that is visible is the search icon. Then when I click on the icon, the EditText appears. How do I get the EditText to be visible from the get go? Here is my xml:

<SearchView
        android:id="@+id/search"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:queryHint="@string/search_hint"
        android:textSize="16sp" />
like image 354
user3093402 Avatar asked Jan 07 '14 18:01

user3093402


1 Answers

EDIT---

Oh sorry! I tought you wanted to do an 'empty' query. I think you can open SearchView programmatically using:

searchView.setIconified(false);

OLD ANSWER--

Inside an Activity you can try with:

onSearchRequested();

And inside a Fragment you can try with:

getActivity().onSearchRequested();

Good luck!

like image 56
pozuelog Avatar answered Oct 11 '22 13:10

pozuelog