问题描述
有没有其他方法可以获取searchview的输入并放入textview中?看来getText() 和setText() 方法不适用于searchview.
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.
或
有没有办法将输入从 EditText 传输到 Searchview?
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());
推荐答案
for searchView to editText
for searchView to editText
editText.setText(searchView.getQuery());
用于将 editText 转换为 SearchView
for editText to SearchView
searchView.setQuery(editText.getText(),false);
http://developer.android.com/reference/android/widget/SearchView.html#getQuery()
这篇关于如何从searchview获取输入到textview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!