-
Notifications
You must be signed in to change notification settings - Fork 3.5k
SearchView setQuery, other customizations not possible? #1029
Comments
I am also having same issue.I am trying to setQuery("test",false); in a method but i dont see the text visible in the searchView.Please fix this. |
I am also having this issue......are there anyone can help to fix it.... |
Your problem is caused by the fact that when you click to expand the SearchView it will call SearchView.onActionViewExpanded() where it sets the text to blank (if you put a breakpoint and debug the code you'll see it): 1289 mQueryTextView.setText(""); Maybe it could set it to mUserQuery instead, I don't know... If what you want to is to default a search value for when the user expands the search view, you could try overriding the OnActionExpandListener, e.g.:
You may notice that inside onMenuItemActionExpand() I am calling searchView.onActionViewExpanded() - if you don't call it in there, it will get called afterwards and it will blank your search value again (again, found by putting a breakpoint in ABS SearchView code). HTH, |
This save me thank you :) |
I picked the code from the demo SearchViews below and added a single line setQuery to searchView in onCreateOptionsMenu method. It didn't work. In fact I see that at least setIconified doesn't work either. Is this behavior expected from creating searchView on onCreateOptionsMenu method ? Because the only way I could make it work is by adding the modified searchView to ActionBar.
The text was updated successfully, but these errors were encountered: