Kri*_*ant 5 android android-custom-view android-layout android-edittext android-search
如何实现搜索编辑文本(如Google播放),并在语音搜索和建议列表的右侧显示后退和取消按钮,应显示在完整的编辑文本布局下方。
这是带有一些自定义的 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>
Run Code Online (Sandbox Code Playgroud)
和 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>
Run Code Online (Sandbox Code Playgroud)
您还需要覆盖 onSearchRequested
@Override
public boolean onSearchRequested() {
Bundle appData = new Bundle();
appData.putBoolean(SearchableActivity.JARGON, true);
startSearch(null, false, appData, false);
return true;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7256 次 |
| 最近记录: |