当前位置: 首页 > news >正文

【Android】自动提示匹配之AutoCompleteTextView

public class

AutoCompleteTextView

extends EditText
implements Filter.FilterListener
java.lang.Object
android.view.View
android.widget.TextView
android.widget.EditText
android.widget.AutoCompleteTextView
Known Direct Subclasses

More Information

Note that using a hard-coded string array is not a recommended design practice because your application code should focus on behavior, not content. Application content such as strings should be externalized from the code in order to make modifications to the content easier and facilitate localization of the content. The hard-coded strings are used in this tutorial only to make it simple and focus on theAutoCompleteTextViewwidget. Instead, your application should declare such string arrays in an XML file. This can be done with a<string-array<resource in your projectres/values/strings.xmlfile. For example:

这里讲hard-coded不利于国际化,我们做的AP应该focus在behavior上而不是content.所以建议把上面的String-array放在String.xml文件中,例如:
<?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="countries_array"> <item>Bahrain</item> <item>Bangladesh</item> <item>Barbados</item> <item>Belarus</item> <item>Belgium</item> <item>Belize</item> <item>Benin</item> </string-array> </resources>

To use these resource strings for theArrayAdapter, replace the originalArrayAdapterconstructor line with the following:
String[] countries = getResources().getStringArray(R.array.countries_array); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, countries);


翻译自: http://developer.android.com/resources/tutorials/views/hello-autocomplete.html

相关文章:

  • 9、ABPZero系列教程之拼多多卖家工具 拼团提醒类库封装
  • 【Android】时间与日期Widget(DatePicker 与 TimePicker)
  • 表单
  • 面试题——二维数组中的查找
  • 使用java poi解析表格
  • 【Android】如何查看每个方法所花费的时间从而进行Performance的调优
  • docker-compose命令
  • 你还在迭代和递归吗?
  • 受欢迎的牛
  • appium自动化安装(一)
  • Template Method模板方法
  • UVA 10603 倒水问题
  • 程序员编程艺术第二十六章:基于给定的文档生成倒排索引(含源码下载)
  • Flume数据采集准备
  • 【Android】Menu不同菜单的使用介绍
  • [数据结构]链表的实现在PHP中
  • 【前端学习】-粗谈选择器
  • 0x05 Python数据分析,Anaconda八斩刀
  • Spring技术内幕笔记(2):Spring MVC 与 Web
  • TCP拥塞控制
  • Transformer-XL: Unleashing the Potential of Attention Models
  • vue自定义指令实现v-tap插件
  • 精益 React 学习指南 (Lean React)- 1.5 React 与 DOM
  • 马上搞懂 GeoJSON
  • 配置 PM2 实现代码自动发布
  • 前端每日实战 2018 年 7 月份项目汇总(共 29 个项目)
  • 什么软件可以剪辑音乐?
  • 小而合理的前端理论:rscss和rsjs
  • 正则表达式小结
  • 如何在招聘中考核.NET架构师
  • ​​​​​​​GitLab 之 GitLab-Runner 安装,配置与问题汇总
  • ​软考-高级-系统架构设计师教程(清华第2版)【第15章 面向服务架构设计理论与实践(P527~554)-思维导图】​
  • ​总结MySQL 的一些知识点:MySQL 选择数据库​
  • # 日期待t_最值得等的SUV奥迪Q9:空间比MPV还大,或搭4.0T,香
  • #NOIP 2014# day.1 生活大爆炸版 石头剪刀布
  • #免费 苹果M系芯片Macbook电脑MacOS使用Bash脚本写入(读写)NTFS硬盘教程
  • (9)STL算法之逆转旋转
  • (delphi11最新学习资料) Object Pascal 学习笔记---第5章第5节(delphi中的指针)
  • (差分)胡桃爱原石
  • (二)Linux——Linux常用指令
  • (附源码)计算机毕业设计ssm高校《大学语文》课程作业在线管理系统
  • (南京观海微电子)——COF介绍
  • (十八)三元表达式和列表解析
  • (一)pytest自动化测试框架之生成测试报告(mac系统)
  • (转)linux下的时间函数使用
  • (转)真正的中国天气api接口xml,json(求加精) ...
  • ..回顾17,展望18
  • .NET 2.0中新增的一些TryGet,TryParse等方法
  • .NET Core、DNX、DNU、DNVM、MVC6学习资料
  • .net framework profiles /.net framework 配置
  • .NET(C#、VB)APP开发——Smobiler平台控件介绍:Bluetooth组件
  • .NET与java的MVC模式(2):struts2核心工作流程与原理
  • .pop ----remove 删除
  • ::前边啥也没有
  • @FeignClient 调用另一个服务的test环境,实际上却调用了另一个环境testone的接口,这其中牵扯到k8s容器外容器内的问题,注册到eureka上的是容器外的旧版本...