How to implement Search Edit text like Google play with Back and Cancel button on Right at place of Voice search and suggestions list should display below the complete edit text layout.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This is SearchView with some customization check the docs http://developer.android.com/guide/topics/search/search-dialog.html
Actvity declared like this
<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>
and 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>
Also you would need to override the onSearchRequested
@Override
public boolean onSearchRequested() {
Bundle appData = new Bundle();
appData.putBoolean(SearchableActivity.JARGON, true);
startSearch(null, false, appData, false);
return true;
}
回答2:
The are some awesome libraries provide the Search view you want, like:
Floating Search View
And more:
https://github.com/lapism/SearchView
https://github.com/Quinny898/PersistentSearch