<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.lesson6_5_id19.MainActivity" >
<!--单个字段扩充提示
completionThreshold是控制用户输入第几个字符开始提示,最小值是1-->
<AutoCompleteTextView
android:id="@+id/actv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="1.请输入联系人"
android:completionThreshold="1"
android:singleLine="true"/> <!-- 多个字段扩充提示 -->
<MultiAutoCompleteTextView
android:id="@+id/mactv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="2.请输入联系人"
android:completionThreshold="1"/> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- 自定义提示筐的TextView -->
<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="显示文本"
android:gravity="center"
android:padding="10dp"
android:background="#ccffcc"
android:textColor="#ff0000"/>
</LinearLayout>
 package com.example.lesson6_5_id19;

 import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.MultiAutoCompleteTextView; public class MainActivity extends Activity {
// 把提示的内容放到一个String数组里面
String[] names = {"zhangshan","lisi","wangwu","zhaoliu",
"zhangshan","lisi","wangwu","zhaoliu",
"zhangshan","lisi","wangwu","zhaoliu",
"zhangshan","lisi","wangwu","zhaoliu",
"zhangshan","lisi","wangwu","zhaoliu",
"zhangshan","lisi","wangwu","zhaoliu",};
AutoCompleteTextView actv;
MultiAutoCompleteTextView mactv;
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
actv = (AutoCompleteTextView) findViewById(R.id.actv);
mactv = (MultiAutoCompleteTextView) findViewById(R.id.mactv);
// 适配器
// 将数据与视图关联在一起
// 系统已经帮我们写好了很多layout
// adapter = new ArrayAdapter<String>(this//1.上下文
// ,R.layout.item_actv_layout//2.布局
// ,R.id.tv//该布局上的TextView的id号
// ,names);//最后一个是数据
// 选择系统的layout,里面的TextView的id号可以忽略不写
adapter = new ArrayAdapter<String>(this, R.layout.activity_item, R.id.tv, names);
//使用“,”来分割。
mactv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
// 将适配器设置到view上
actv.setAdapter(adapter);
//设置适配器之前,必须要知道分隔符是什么样的。
mactv.setAdapter(adapter);
}
}

最新文章

  1. maven---install报错
  2. 完美C++(第5版)(双色)
  3. Python之SQLAlchemy学习--外键约束问题
  4. Sublime Text2 安装Package Control
  5. jquery 删除字符串最后一个字符的方法
  6. 帝国CMS商城功能高级使用
  7. java语言基础02
  8. 51nod贪心算法入门-----任务分配问题
  9. Lambda表达式转SQL语句类库
  10. loadrunner controller:集合点策略
  11. 使用Swashbuckle构建RESTful风格文档
  12. 利用kibana插件对Elasticsearch进行bool查询
  13. Scrapy实战篇(六)之爬取360图片数据和图片
  14. 初学c# -- 纯属无聊,写下棋
  15. [转]linux 调用动态库so文件
  16. Anaconda下载及安装及查看安装的Python库用法
  17. element ui里dialog关闭后清除验证条件
  18. [osg][osgEarth][原]基于OE自定义自由飞行漫游器(初级版)
  19. 大数据入门第十四天——Hbase详解(二)基本概念与命令、javaAPI
  20. day15(mysql之零碎知识)

热门文章

  1. Snmp在Windows下的实现----WinSNMP编程原理
  2. PTA-数据结构 Dijkstra 城市间紧急救援
  3. aidl笔记 2/5/2015
  4. 【旧文章搬运】加载PE文件时IAT的填充时机
  5. 【旧文章搬运】为什么win32k.sys在System进程空间无法访问
  6. 使用 DDMenuController 类的方法(非常好用的抽屉类)
  7. codevs-1204
  8. Flutter实战视频-移动电商-62.购物车_首页Provide化 让跳转随心所欲
  9. 利用ant 和 Junit 生成测试报告
  10. sql #与$的区别