输入哪个关键字进行匹配怎么做
想要设置输入自己想要的字符时进行匹配,或者是输入第几个字符时进行匹配,怎么写代码
想要设置输入自己想要的字符时进行匹配,或者是输入第几个字符时进行匹配,怎么写代码
2016-10-22
private AutoCompleteTextView autoCompleteTextView;//3个步骤
private MultiAutoCompleteTextView multiAutoCompleteTextView;
private String[] p={"这个是你提前写好的可以搜索的东西","","",""};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_er);
button=(Button) findViewById(R.id.button2);//按钮事件
//实例化
autoCompleteTextView=(AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
//适配器,创建一个ArrayAdapter适配器
//初始化数据源,通俗的理解就是输入字符后需要匹配的内容
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, p);
//将adapter和autoCompleteTextView绑定
autoCompleteTextView.setAdapter(adapter);
multiAutoCompleteTextView=(MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1);
multiAutoCompleteTextView.setAdapter(adapter);
multiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
举报