//输入,可自动搜所 String[] searchList = {"a1","aa1","b1","bb1","c1","c2","123"}; AutoCompleteTextView autoCompleteTextView = findViewById(R.id.edit_layout_auto_compelete); ArrayAdapter<String> adapterArr = new ArrayAdapter<String>(this,R.layout.auto_complete_layout,searchList); autoCompleteTextView.setAdapter(adapterArr);
<AutoCompleteTextView android:id="@+id/edit_layout_auto_compelete" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionHint="条件搜所" android:completionThreshold="1" ></AutoCompleteTextView>
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="20sp"> </TextView>