这几天使用到了搜索,没仔细深入,步骤大概是这样的

1.Activity中调用onSearchRequested();

2.AndroidManifest.xml中添加

<meta-data android:name="android.app.searchable"  android:resource="@xml/searchable"/> 

@xml/searchable是自定义的,内容如下

<?xml version="1.0" encoding="utf-8"?>   <searchable xmlns:android="http://schemas.android.com/apk/res/android"      android:label="@string/searchLabel" android:hint="@string/searchHint"    android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"    >   </searchable>

3.点击@xml/searchable中的按钮的时候,android会搜索AndroidManifest.xml中的

<meta-data android:name="android.app.default_searchable" android:value=".SerachActivity" /> 

4.SerachActivity是自定义的Activity,通过以下代码

Intent intent = getIntent();String action = intent .getAction();if (Intent.ACTION_SEARCH.equals(action )) {String queryString = intent.getStringExtra(SearchManager.QUERY);//queryString是查询的字符串}
流程是这样的,有错误请指出,谢谢

更多相关文章

  1. 2011.07.11(3)——— android xliff字符串操作
  2. android环境搭建步骤
  3. 界面编程之基本界面组件(5)ToggleButton(状态开关按钮)
  4. android Button 切换背景,实现动态按钮和按钮颜色渐变
  5. android点击按钮控制图片切换-kotlin
  6. 选择框在右边的单选按钮。。
  7. android : 圆角按钮 shape属性
  8. 使用多状态按钮ToggleButton
  9. Android如何避免输入法弹出时遮挡住按钮或输入框

随机推荐

  1. 通过keep-alive实现了解vue组件实现原理(3
  2. Python中的IDLE是什么?常用功能介绍!
  3. 浅谈Web安全常见问题
  4. 最新整理:iOS面试题-面试常问问题(一)
  5. centos 7.6 yum搭建open***服务端以及客
  6. docker部署tomcat(centos8测试)
  7. 源码分析vuex如何维护多个组件的数据共享
  8. Access和Python学哪个好?学习分享!
  9. Android工程师
  10. 快递单号批量查询软件,自动识别快递单号派