Android--输入自动提示AutoCompleteTextView
布局文件:
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title" /> <AutoCompleteTextView
android:id="@+id/actv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"/>
Activity代码:
package cn.luxh.autocomplete; import android.os.Bundle;
import android.app.Activity;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.actv);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,getData());
//设置适配器
actv.setAdapter(adapter);
//输入一个字符开始提示
actv.setThreshold(1);
} /**
* 模拟数据
* @return
*/
private String[] getData(){
String[] names = {
"Dwight D. Eisenhower",
"John F. Kennedy",
"Lyndon B. Johnson",
"Richard Nixon",
"Gerald Ford",
"Jimmy Carter",
"Ronald Reagan",
"George H. W. Bush",
"Bill Clinton",
"George W. Bush",
"Barack Obama"};
return names;
} }
运行效果:
Android--输入自动提示AutoCompleteTextView的更多相关文章
- jquery 实现邮箱输入自动提示功能:(二)
上篇文章写到了一个不错的jquery实现邮箱输入自动提示功能,发现还有一个不错的自动提示插件: 先展示结果如图: html代码: <center> <h1>输入邮箱试试!< ...
- jquery 实现邮箱输入自动提示功能:(一)
记得去年做某个项目的时候,用到了邮箱输入自动提示功能,于是网上搜了一下,发现了这个写得不错,现在回想起来,转载一下,方便查阅. 邮箱的广泛使用得益于它的免费,因此很多网站在注册的时候都会直接使用邮箱作 ...
- Eclipse Android 代码自动提示功能
Eclipse Android 代码自动提示功能 Eclipse for android 实现代码自动提示智能提示功能,介绍 Eclipse for android 编辑器中实现两种主要文件 java ...
- Android搜索自动提示功能 AutocompleteTextView
1.配置main.xml中自动提示控件: <AutoCompleteTextView android:id="@+id/autotv_searchresult" androi ...
- jquery 实现邮箱输入自动提示功能
邮箱的广泛使用得益于它的免费,因此很多网站在注册的时候都会直接使用邮箱作为账号名 为了提高用户的体验,很多网站都会实现邮箱输入的自动提示功能,所有自己也实现了一个,先看下效果吧,觉得效果还行的就拿去 ...
- [转]Android 代码自动提示功能
源地址http://blog.sina.com.cn/s/blog_7dbac12501019mbh.html 或者http://blog.csdn.net/longvslove/article/de ...
- Android 代码自动提示功能
Eclipse for android 实现代码自动提示智能提示功能,介绍 Eclipse for android 编辑器中实现两种主要文件 java 与 xml 代码自动提示功能,解决 eclips ...
- Eclipse For Android 代码自动提示功能
Eclipse for android 实现代码自动提示智能提示功能,介绍 Eclipse for android 编辑器中实现两种主要文件 java 与 xml 代码自动提示功能,解决 eclips ...
- 用jQuery的ajax的功能实现输入自动提示的功能
注意事项:要使用jQuery首先要把它的包引用进来( <script type="text/javascript" language="javascript&quo ...
随机推荐
- 006 [翻译] Haneke(一个Swfit iOS缓存类)
Github项目地址:https://github.com/Haneke/HanekeSwift Haneke是一个用swift写成的轻量级iOS类,以简单好用著称(design-decisions- ...
- ORA-01013:用户请求取消当前的操作
ORA-01013:用户请求取消当前的操作 在测试一个通过ODBC连接ORACLE数据库的VB程序时,总是出现该错误,估计应该是数据量比较大,导致超时. 查到解决方法有如下四种 (选任意一种即可): ...
- Redis学习手册(List数据类型)
一.概述: 在Redis中,List类型是按照插入顺序排序的字符串链表.和数据结构中的普通链表一样,我们可以在其头部(left)和尾部(right)添加新的元素.在插入时,如果该键并不存在,Redis ...
- mongoDB 下载/安装/客户端笔记
1.下载: https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-3.0.3.zip 2.安装 1.解压mongodb-win32-x86 64- ...
- Andaroid L新特性
1.Material Design”(材料设计)的全新设计理念,和Holo相比,Material Design更加色彩丰富,不像Holo那样灰暗 2.1)卡片风格(锁屏界面) 2)环动式设计 And ...
- smarty模板基础
将前台后台隔离,前台控制显示,后台控制逻辑/内容,与cms类似 原理: 用户访问text.php页面,后台调用类smarty.class.php显示静态模板;
- linux crontab 实现每秒执行(转)
linux crontab 命令,最小的执行时间是一分钟.如需要在小于一分钟内重复执行,可以有两个方法实现. 1.使用延时来实现每N秒执行 创建一个php做执行动作,非常简单,就是把当前时间写入log ...
- 用Opera Mobile调试手机版网页【转】
注意:新版本的opera已经采用webkit内核,没有dragonfly了. 要下载12版的http://get.geo.opera.com/pub/opera/win/1216/int/Opera_ ...
- Spark1.6 DataSets简介
Apache Spark提供了强大的API,以便使开发者为使用复杂的分析成为了可能.通过引入SparkSQL,让开发者可以使用这些高级API接口来从事结构化数据的工作(例如数据库表,JSON文件),并 ...
- 用CRT connect MongoDB 使用Backspace无效
这是个很蛋疼的小问题... 使用./mongo 10.1.235.62:27017 连接上后 打错了无法删除!? 这是在逗我,那就修改CRT个设置,点击选项,会话选项,仿真,把终端改成Linux就行了 ...