AutoCompleteTextView在 输入数据时可以出现提
//1.获得AutoCompleteTextView
AutoCompleteTextView at=(AutoCompleteTextView) findViewById(R.id.att);
at.setThreshold(1);//设置输入几个字符长度便于出现提示文本
//2.构建Adapter
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,
new String[]{"KK","JJJ","GGG","DDD","YYYY2020"});
//3.关联Adapter
at.setAdapter(adapter);
布局如下
<AutoCompleteTextView
android:id="@+id/att"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="please input" />
本文标题:AutoCompleteTextView在 输入数据时可以出现提
本文链接:https://www.haomeiwen.com/subject/vizwdhtx.html
网友评论