我试图找到一种为SearchView设置文本的方法,但我找不到任何东西?有没有人知道这样做的任何方法?例如这样的事情
searchView.setText("blah blah");
试试这个使用setQuery
setQuery(CharSequence query, boolean submit)
在文本字段中设置查询字符串,并可选择提交查询。
示例代码
使用intent将标题发送到另一个活动
Intent intent=new Intent(this, OtherActivity.class);
intent.putExtra("TITLE", "NILESH");
startActivity(intent);
在此类其他活动中检索标题
String str = getIntent().getStringExtra("TITLE");
searchView.setQuery(str, false);
//1st activity
Intent intent=new Intent(view.getContext(), 2ndActivity.class);
intent.putExtra("key", someValue);
startActivity(intent);
//2nd activity
String value="";
Intent intent=getIntent();
Bundle bundle=intent.getExtras();
if(bundle!=null)
{
mealId=bundle.getString("key");
}
既然你在第二项活动中获得了价值,那么其他事情就很简单。