1.控件属性:
//设置在输入第几个字符时开始自动匹配
android:completionThreshold="2"
2.AutoCompleteTextView的使用方法:
//1.声明
private AutoCompleteTextView acTextView;
private String[] res = {"hello", "helllo", "hellllo", "hail", "haill", "haillll"};
//2.初始化控件
acTextView =(AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
//3.创建按一个适配器
ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1, res);
//4.将适配器与控件绑定
acTextView.setAdapter(adapter);
3.MultiAutoCompleteTextView的使用方法:
//1.声明
private MultiAutoCompleteTextView macTextView;
private String[] res = {"hello", "helllo", "hellllo", "hail", "haill", "haillll"};
//2.初始化控件
macTextView = (MultiAutoCompleteTextView)findViewById(R.id.multiAutoCompleteTextView1);
//3.创建按一个适配器
ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this, android.R.layout.simple_list_item_1, res);
//4.绑定适配器
macTextView.setAdapter(adapter);
//5.设置分隔符为逗号
macTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());