关于android中搜索功能的实现

在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="?"
-->
 
原文地址:https://www.cnblogs.com/cwr941012/p/4909983.html