关于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="?"
-->
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步