Reputation: 302
Is there another way to get the input of searchview and put it into textview? It seems that the getText() and setText() method are not applicable to searchview.
Or
Is there a way to transfer the input from EditText to Searchview?
Please help me to look for necessary resources/codes/method about the above question. Thank you. Here is my code:
public boolean onQueryTextChange(String newText) {
// TODO Auto-generated method stub
showResults(newText);
return false;
}
@Override
public boolean onQueryTextSubmit(String query) {
// TODO Auto-generated method stub
tvInput = (TextView) findViewById (R.id.tvInput);
showResults(query);
// searchView.getQuery().toString();
tvInput.setText(searchView.getQuery().toString());
return false;
}
I also do it in other way. Here:
tvInput = (TextView) findViewById (R.id.tvInput);
tvInput.setText(searchView.getQuery());
Upvotes: 11
Views: 22912
Reputation: 13917
for searchView to editText
editText.setText(searchView.getQuery());
for editText to SearchView
searchView.setQuery(editText.getText(),false);
http://developer.android.com/reference/android/widget/SearchView.html#getQuery()
Upvotes: 20