自动补齐控件
来源:互联网 发布:linux 创建新文件 编辑:程序博客网 时间:2024/05/16 13:39
1.在XML配置控件(两种有MultiAutoCompleteTextView和AutoCompleteTextView)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <MultiAutoCompleteTextView android:id="@+id/tv_multiAuto" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:completionThreshold="1" /> <AutoCompleteTextView android:id="@+id/tv_auto" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:completionThreshold="1" /></LinearLayout>
2.实例化两种控件
private MultiAutoCompleteTextView multiAutoComplete;private AutoCompleteTextView autoCompleteTextView;
this.multiAutoComplete = (MultiAutoCompleteTextView) findViewById(R.id.tv_multiAuto);this.autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.tv_auto);
3.准备数据源,在下拉列表显示的数据
String[] datas = new String[]{ "Hello", "Hay", "Ha", "World", "Word", "Wa!"};
4.设置适配器,为控件填充数据
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,datas);this.multiAutoComplete.setAdapter(adapter);this.autoCompleteTextView.setAdapter(adapter);
5.假如是多个补齐控件还可以设置间隔符
this.multiAutoComplete.setTokenizer( new MultiAutoCompleteTextView.CommaTokenizer());
阅读全文
0 0
- 自动补齐控件
- 自动补全控件
- AutoCompleteExtender 自动补全控件
- FreeBSD 自动补齐
- python 自动补齐
- shell----自动补齐
- 自定义控件-MultipleTextView(自动换行、自动补齐宽度的排列多个TextView)
- 【Android】自定义控件实现自动补齐邮箱后缀的输入框
- Android autocompleteTextview自动补齐
- AutoCompleteTextView,MultiAutoCompleteTextView 自动补齐
- notepad++自动补齐括号
- Python shell自动补齐
- Elasticsearch 自动补齐建议
- vim 代码自动补齐
- Racer: 自动补齐神器
- webstorm自动补齐快捷键
- 淘宝的一个自动补全提示的控件收藏
- 淘宝的一个自动补全提示的控件收藏
- 原生js操作dom
- 通过bindService调用服务里面的方法
- HTTP状态码(HTTP Status Code)
- 获取分类下贴吧(文章)
- librtmp协议分析---RTMP_SendPacket函数
- 自动补齐控件
- Python 爬虫入门(requests)
- socket网络通信
- win10下RabbitMQ环境搭建
- pyenv
- Android三种播放视频的方式
- Mybatis中,当插入数据后,返回最新主键id的几种方法,及具体用法
- 主页被强制绑定为360导航
- 转置的好用的cuda程序