AutoCompleteTextView实现自动搜索

一,布局
//android:completionThreshold="1" //表示输入一个字母就开始搜索

android:completionThreshold="1"
android:hint="请输入需要搜索的内容"
android:id="@+id/autoCompleteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

二,代码

  //EditText米有setAdapter()方法
    AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
    ArrayAdapter stringArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1,
            result_arr);
    autoCompleteTextView.setAdapter(stringArrayAdapter);

你可能感兴趣的:(AutoCompleteTextView实现自动搜索)