Here is how to set text searchquery in a searchview and submit in android studio java
Setting text in a searchview helps to load an already created query, for example – imagine you have a wallpaper app, you want search for love wallpapers, so you usually type “love” in searchview and clicks the submit.
But what if you can set that love text programmatically in that searchview? and align it to a button click, like drawer menu, option menu etc? then your users can just search predefined keywords without typing.
Here is how to do it
Setting text automatic in the searchview text input field on android java
SearchView searchView = (SearchView) searchMenuItem.getActionView(); String love = "love"; searchView.setQuery(love, true);
This is it, just hook up this code with a button