如何解决更改搜索对话框
| 是否可以在我的活动中更改“搜索对话框”(Android 3.0之前的版本)?当您按下硬件搜索按钮时,该搜索栏会下拉。通过更改,我的意思是修改布局。如果可以的话,我想添加一个附加按钮。解决方法
我想浮动搜索框就是你想要的〜
并不困难,但它的配置却有点复杂〜
首先,您需要配置搜索栏的参数
新建一个searchable.xml配置文件,如下所示:
<searchable xmlns:android=http://schemas.android.com/apk/res/android
<!-- label is the text at the bottom of the search bar,hint is the text in the search bar -->
android:label=\"@string/search_label\"
android:hint=\"@string/search_hint\"
android:searchMode=\"showSearchLabelAsBadge\"
<!-- voice search -->
android:voiceSearchMode=\"showVoiceSearchButton|launchRecognizer\"
android:voiceLanguageModel=\"free_form\"
android:voicePromptText=\"@string/search_invoke\"
<!-- Configure search suggestions-->
android:searchSuggestAuthority=\"com.android.cbin.SearchSuggestionSampleProvider\"
android:searchSuggestSelection=\" ? \"
/>
您应该在mainfest.xml中执行此操作:
<activity android:name=\"SearchResultActivity\">
<intent-filter>
<action android:name=\"android.intent.action.SEARCH\"></action>
</intent-filter>
<!-- searchable.xml -->
<meta-data android:resource=\"@xml/searchable\"
android:name=\"android.app.searchable\"></meta-data>
</activity>
<!-- For each Activity can use search bar,be sure to start the label into the Activity
in which the value is the search results-->
<meta-data android:name=\"android.app.default_searchable\"
android:value=\".SearchResultActivity\"
/>
<provider android:name=\"SearchSuggestionSampleProvider\"
android:authorities=\"com.android.cbin.SearchSuggestionSampleProvider\"></provider>
然后覆盖Activity的onSearchRequested函数
几乎像这样,忘了细节〜。〜!!!
祝你好运
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。