如何为搜索对话框文本 - Android电子 [英] How to set the Text for Search Dialog - Android

查看:120
本文介绍了如何为搜索对话框文本 - Android电子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否有人就如何设置一个特定的文本搜索对话框通知我来帮助?我知道如何设置一个暗示,我这样做是通过XML文件。不过,我想按什么去年搜索文本设置为搜索对话框。我计划通过共享preference检索这一点。我只是不知道如何设置的文本。

Can some one assist in advising me on how to set a specific text to the Search Dialog? I know how to set a "hint", I do this through the xml file. But I would like to set the text to the Search dialog according to what was last searched for. I plan on retrieving this through SharedPreference. I just do not know how to set the text.

感谢

推荐答案

通过查询字符串作为额外的意图,并在您的搜索活动,检索,如下图所示:

Pass the query string as intent extra and in your Search Activity, retrieve it as shown below:

@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

这篇关于如何为搜索对话框文本 - Android电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆