关于android中搜索功能的实现
2015-10-25 23:15
756 查看
在android应用中,为了有良好的用户体验,需要提供搜索功能,在android中通过系统提供的 SearchManager来进行实现,
对Search的访问只能通过系统提供的context.getSystemService(Context.SEARCH_SERVICE)来进行实现,不能对SearchManager进行初始化
需要在res/xml下面添加一个配置文件
核心为
<serchable
xmls:android:"......"
android:hint="@string/searchHint"
android:label="@string/searchLable"
android:searchMode="ShowSearchLabelAsBadge"
android:searchSuggestAuthority="com.anroid.coding.SearchSuggestionSampleProvider"
android:searchSuggestSelection="?">
</serchable>
<!-- Label 为搜索框上面的文本,hint为搜索框里面的提示文本
-->
android:hint="@string/searchHint"
android:label="@string/searchLabel"
<!-- 语音搜索配置
android:voiceSearchMode:="showVoiceSearchButton|launchRecognizer"
android:voiceLanguageModel="free_from"
android:voicePromptText="@string/search_invoke"
-->
<!-- 配置搜索建议
searchSuggesteAuthority的值必须是继承自SearchRecentSuggestionsProvider的完整路径名
android:searchSuggesterAuthority="com.anroid.coding.SearchSuggestionSampleProvider"
android:searchSuggestSelection="?"
-->
对Search的访问只能通过系统提供的context.getSystemService(Context.SEARCH_SERVICE)来进行实现,不能对SearchManager进行初始化
需要在res/xml下面添加一个配置文件
核心为
<serchable
xmls:android:"......"
android:hint="@string/searchHint"
android:label="@string/searchLable"
android:searchMode="ShowSearchLabelAsBadge"
android:searchSuggestAuthority="com.anroid.coding.SearchSuggestionSampleProvider"
android:searchSuggestSelection="?">
</serchable>
<!-- Label 为搜索框上面的文本,hint为搜索框里面的提示文本
-->
android:hint="@string/searchHint"
android:label="@string/searchLabel"
<!-- 语音搜索配置
android:voiceSearchMode:="showVoiceSearchButton|launchRecognizer"
android:voiceLanguageModel="free_from"
android:voicePromptText="@string/search_invoke"
-->
<!-- 配置搜索建议
searchSuggesteAuthority的值必须是继承自SearchRecentSuggestionsProvider的完整路径名
android:searchSuggesterAuthority="com.anroid.coding.SearchSuggestionSampleProvider"
android:searchSuggestSelection="?"
-->
相关文章推荐
- Android:重写ViewPager实现Fragment的自由替换
- Android模块化编程之引用本地的aar
- OpenCV4android org.opencv.feature2d
- Android Support Design 控件 FloatingActionButton
- Android Support Design 控件 FloatingActionButton
- 对话框形式的activity
- 怎样在android中添加背景图片?
- android上使用opencv遇到的一点问题
- android Push 服务的消息
- Android:Using shared element transitions in fragments
- Android五大布局方式——相对布局(RelativeLayout)属性详解
- Android中让GIF图片动起来
- Android-ActionBar扩展
- android studio ,Gradle DSL method not found: 'compile()'
- androidStudio gradle 编译基础
- [转]Android--多线程之Handler
- Android五大布局方式详解
- Android activity属性设置整理
- Android点击控件改变颜色的两种方法——onTouchLisener()和xml资源文件selector的使用
- Android中BindService方式使用的理解