当前位置:网站首页>AutoCompleteTextView(输入框预匹配)
AutoCompleteTextView(输入框预匹配)
2022-07-27 17:02:00 【Ashurol】
//AutoCompleteTextView,MultiAutoCompleteTextView的区别:MultiAutoCompleteTextView可以定义分隔符,匹配多项。
public class MainActivity extends ActionBarActivity {
AutoCompleteTextView auto1;
MultiAutoCompleteTextView auto2;
String res[]={"nihao","hello","hi"};
String res2[]={"zhangsan","lisi","laowang"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
auto1=(AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,res);
auto1.setAdapter(adapter);
auto2=(MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1);
ArrayAdapter<String> adapter2=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,res2);
auto2.setAdapter(adapter2);
// 设置以逗号为分隔符作为结束的字符
auto2.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
}
}<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.xin.autocompletetextview.MainActivity" >
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入内容" >
</AutoCompleteTextView>
<MultiAutoCompleteTextView
android:id="@+id/multiAutoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入联系人" >
</MultiAutoCompleteTextView>
</LinearLayout>
边栏推荐
- 查看宝塔PHP扩展目录
- Complex number proof of solvability of regular 17 sided ruler and gauge drawing
- c语言:6、指针的简单使用与注意事项
- 开启和禁用hyper-v
- 零知识证明的硬件加速
- Intel's process roadmap for the next 10 years is exposed: 1.4nm process will be launched in 2029! How?
- [basic knowledge of deep learning - 49] kmeans
- c语言:10、输入流,输出流,错误流
- 27、golang基础-互斥锁、读写锁
- A lock faster than read-write lock. Don't get to know it quickly
猜你喜欢

S32K系列芯片--简介
技术实践干货 | 初探大规模 GBDT 训练

Debian夺回“debian.community“ 域名,喷子仍不善罢甘休

正十七边形尺规作图可解性复数证明

Take byte offer in four rounds and answer the interview questions

【深度学习基础知识 - 46】贝叶斯定理与条件概率公式

C language: 5. Multidimensional array

Chinese character search Pinyin wechat applet project source code

5W奖金池/面向高校,2022法律科技创新大赛报名火热进行中

A low code development platform that brings high-value user experience
随机推荐
c语言:12、gdb工具调试c程序
英特尔推出全球最小的高分辨率激光雷达,售价仅349美元
Introduction to several wireless protocols
TSMC 5nm is about to mass produce: Apple A14 monopolizes 70% of the production capacity, and Huawei Kirin 1020 takes 30%
台积电5nm即将量产:苹果A14独占7成产能,华为麒麟1020拿下3成
Hdu1573 x problem [univariate linear congruence equations]
Hardware acceleration of zero knowledge proof
[Huawei cloud stack] [shelf presence] issue 13: have you seen the decoupling architecture of the management area? Help government and enterprise customers solve big problems
嵌入式C语言结构体
[basic knowledge of deep learning - 48] characteristics of Bayesian network
Embedded C language pointer alias
查看宝塔PHP扩展目录
【深度学习基础知识 - 39】BN、LN、WN的比较
Original pw4203 step-down 1-3 lithium battery charging chip
I want to consult. Our maxcompute spark program needs to access redis, development environment and production environment redis
大佬们,ORACLE CDC,本地运行,老是遇到这个An exception occurred in
c语言:10、输入流,输出流,错误流
The first Xiaolong 765G! Redmi K30 5g release: support 5g dual-mode 120Hz screen, priced from 1999 yuan
【深度学习基础知识 - 50】PCA降维 主成成分分析
C language: 13. Pointer and memory