小智 1
我想浮动搜索框就是你想要的~\n并不难,但是配置稍微复杂一些~\n首先你需要配置搜索栏的参数\n新建一个searchable.xml配置文件,如下所示:
\n\n<searchable xmlns:android=http://schemas.android.com/apk/res/android\n\n\xe3\x80\x80\xe3\x80\x80<!-- label is the text at the bottom of the search bar\xef\xbc\x8chint is the text in the search bar -->\n android:label="@string/search_label"\n android:hint="@string/search_hint" \n android:searchMode="showSearchLabelAsBadge"\n\n\xe3\x80\x80\xe3\x80\x80<!-- voice search -->\n android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"\n android:voiceLanguageModel="free_form"\n android:voicePromptText="@string/search_invoke"\n\n\n <!-- Configure search suggestions-->\n\n\xe3\x80\x80\xe3\x80\x80 android:searchSuggestAuthority="com.android.cbin.SearchSuggestionSampleProvider"\n android:searchSuggestSelection=" ? "\n/>\nRun Code Online (Sandbox Code Playgroud)\n\n你应该在 mainfest.xml 中执行此操作:
\n\n<activity android:name="SearchResultActivity">\n<intent-filter>\n<action android:name="android.intent.action.SEARCH"></action>\n</intent-filter>\n\n\xe3\x80\x80\xe3\x80\x80\xe3\x80\x80\xe3\x80\x80\xe3\x80\x80\n<!-- searchable.xml -->\n\n<meta-data android:resource="@xml/searchable"\n\n\xe3\x80\x80\xe3\x80\x80\xe3\x80\x80android:name="android.app.searchable"></meta-data>\n\n</activity>\n<!-- For each Activity can use search bar,\n be sure to start the label into the Activity \nin which the value is the search results-->\n<meta-data android:name="android.app.default_searchable"\n android:value=".SearchResultActivity"\n/>\n\n<provider android:name="SearchSuggestionSampleProvider"\n\nandroid:authorities="com.android.cbin.SearchSuggestionSampleProvider"></provider>\nRun Code Online (Sandbox Code Playgroud)\n\n然后重写Activity的onSearchRequested函数
\n\n差不多这样\xef\xbc\x8c忘记细节~\xe3\x80\x82~\xef\xbc\x81\xef\xbc\x81\xef\xbc\x81
\n\n祝你好运~
\n| 归档时间: |
|
| 查看次数: |
574 次 |
| 最近记录: |