0
有人能帮助我建议如何设置一个特定的文本到搜索对话框吗?我知道如何设置“提示”,我通过xml文件执行此操作。但我想根据上次搜索的内容将文本设置到搜索对话框。我打算通过SharedPreference检索它。我只是不知道如何设置文本。如何设置搜索对话框的文本 - Android
感谢
有人能帮助我建议如何设置一个特定的文本到搜索对话框吗?我知道如何设置“提示”,我通过xml文件执行此操作。但我想根据上次搜索的内容将文本设置到搜索对话框。我打算通过SharedPreference检索它。我只是不知道如何设置文本。如何设置搜索对话框的文本 - Android
感谢
传递查询字符串作为额外的意图在您的搜索活动,找回它,如下图所示:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
// Get the intent, verify the action and get the query
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
doMySearch(query);
}
}
参考 - http://developer.android.com/guide/topics/search/search-dialog.html#ReceivingTheQuery
感谢您的答复。我了解如何检索搜索查询,我的意思是如何在上次搜索的对话框中显示搜索词。例如,一个人输入“托尼布莱尔”,按搜索,连接问题随之而来,但他的搜索词仍然存在,并在搜索对话框中可见。因此,他不必再次键入它......我只是不知道如何设置文本到搜索对话框。 – david 2014-12-03 08:35:11