6
是否可以在我的活动中更改搜索对话框(Android 3.0之前)?这是您按下硬件搜索按钮时会下降的搜索栏。通过改变,我的意思是修改布局。如果可以的话,我想添加一个额外的按钮。更改搜索对话框
是否可以在我的活动中更改搜索对话框(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>
然后覆盖活动
的onSearchRequested功能差不多是这样,忘了细节〜。〜!!!
好运〜
问题[这里](http://stackoverflow.com/questions/4150904/android-custom-quick-搜索框)看起来像你所需要的。看来,要走的路是在您的活动中拦截“onSearchRequested”并创建自己的界面。 – Craigy 2011-10-23 20:57:44
你可以轻松地做到这一点。请参阅此处的答案:http://stackoverflow.com/a/44131089/3649347 – GeekOnJava 2017-05-23 10:14:49