如何在Android中设置SearchView文本

Pro*_*mer 2 android searchview android-search

我尝试找到一种为SearchView设置文本的方法,但找不到任何内容?有谁知道这样做的任何方法吗?例如这样的事情

 searchView.setText("blah blah");
Run Code Online (Sandbox Code Playgroud)

Nil*_*hod 5

试试这个使用setQuery

setQuery(CharSequence查询,布尔值提交)

在文本字段中设置查询字符串,还可以选择提交查询。

样例代码

使用意图将标题发送给其他活动

Intent intent=new Intent(this, OtherActivity.class);
intent.putExtra("TITLE", "NILESH");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

像这样在其他活动中检索标题

String str = getIntent().getStringExtra("TITLE");
searchView.setQuery(str, false);
Run Code Online (Sandbox Code Playgroud)