Android--多选自动搜索提示
2015-01-24 22:21
302 查看
一. 效果图
常见效果,在搜素提示选中之后可以继续搜索添加,选中的词条用特殊字符分开
二. 布局代码
三. 设置数据源
此用法和上一篇的AutoCompleteTextView的用法基本一致,只是在后面添加了一个Token分割的问题
四. 测试中不显示搜索词条问题
如上效果图,在搜索的词条中是存在的,搜索提示框也出现了,但是没有出现提示框中的内容,这样主要是因为Android主题导致的,因为颜色的冲突导致内容未能够显示出来
解决方法如下:
将AndroidManifest.xml 文件中的如上代码 主题 android:theme="@style/AppTheme" 删除或者替换为其他主题即可
常见效果,在搜素提示选中之后可以继续搜索添加,选中的词条用特殊字符分开
二. 布局代码
<MultiAutoCompleteTextView android:id="@+id/autoMulti" android:layout_width="match_parent" android:layout_height="60dp" android:layout_marginTop="50dp" />
三. 设置数据源
private void bind(){ MultiAutoCompleteTextView autoText=(MultiAutoCompleteTextView)findViewById(R.id.autoMulti); ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, items); autoText.setAdapter(adapter); autoText.setThreshold(1); autoText.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); }
此用法和上一篇的AutoCompleteTextView的用法基本一致,只是在后面添加了一个Token分割的问题
四. 测试中不显示搜索词条问题
如上效果图,在搜索的词条中是存在的,搜索提示框也出现了,但是没有出现提示框中的内容,这样主要是因为Android主题导致的,因为颜色的冲突导致内容未能够显示出来
解决方法如下:
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
将AndroidManifest.xml 文件中的如上代码 主题 android:theme="@style/AppTheme" 删除或者替换为其他主题即可
相关文章推荐
- Android搜索自动提示功能 AutocompleteTextView
- Android:控件AutoCompleteTextView 客户端保存搜索历史自动提示
- Android:控件AutoCompleteTextView 客户端保存搜索历史自动提示
- Android基础教程(八)之仿百度谷歌搜索自动提示框-----AutoCompleteTextView的应用
- Android:控件AutoCompleteTextView 客户端保存搜索历史自动提示
- Android 利用AutoCompleteTextView实现模糊搜索功能,搜索结果自动提示,识别拼音首字母并转汉字提示
- Android:控件AutoCompleteTextView 客户端保存搜索历史自动提示
- Android 仿百度谷歌搜索自动提示框,将搜索记录保存数据库
- Android:控件AutoCompleteTextView 客户端保存搜索历史自动提示
- Android基础教程(八)之仿百度谷歌搜索自动提示框-----AutoCompleteTextView的应用
- Android:控件AutoCompleteTextView 客户端保存搜索历史自动提示
- Android基础教程(八)之仿百度谷歌搜索自动提示框-----AutoCompleteTextView的应用
- Android:控件AutoCompleteTextView 客户端保存搜索历史自动提示
- Android--自动搜索提示
- Android搜索自动提示功能
- Android仿百度谷歌搜索自动提示框AutoCompleteTextView简单应用示例
- google搜索自动提示下拉菜单
- Android自动提示--AutoCompleteTextView、MultiAutoCompleteTextView
- Android文本自动提示框的简单应用实例
- jquery最新插件Autocomplete搜索自动提示功能