【发布时间】:2015-09-16 04:12:48
【问题描述】:
【问题讨论】:
标签: android android-layout android-edittext android-custom-view android-search
【问题讨论】:
标签: android android-layout android-edittext android-custom-view android-search
这是带有一些自定义的 SearchView 查看文档http://developer.android.com/guide/topics/search/search-dialog.html
这样声明的活动
<activity android:name=".SearchableActivity"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
和 SearchView xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" >
</searchable>
您还需要覆盖 onSearchRequested
@Override
public boolean onSearchRequested() {
Bundle appData = new Bundle();
appData.putBoolean(SearchableActivity.JARGON, true);
startSearch(null, false, appData, false);
return true;
}
【讨论】:
有一些很棒的库可以提供您想要的搜索视图,例如:
Floating Search View
还有更多:
https://github.com/lapism/SearchView
https://github.com/Quinny898/PersistentSearch
【讨论】: