干嘛的--AutoCompleteTextView

java.lang.Object
   ↳	android.view.View
 	   ↳	android.widget.TextView
 	 	   ↳	android.widget.EditText
 	 	 	   ↳	android.widget.AutoCompleteTextView

结论:说白了就是一个带自动提示的输入框。

示例代码:

 public class CountriesActivity extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         setContentView(R.layout.countries);

         ArrayAdapter adapter = new ArrayAdapter(this,
                 android.R.layout.simple_dropdown_item_1line, COUNTRIES);
         AutoCompleteTextView textView = (AutoCompleteTextView)
                 findViewById(R.id.countries_list);
         textView.setAdapter(adapter);
     }

     private static final String[] COUNTRIES = new String[] {
         "Belgium", "France", "Italy", "Germany", "Spain"
     };
 }
 

注意:默认情况需要输入两个字符才会自动提示,修改使用

textView.setThreshold(1);
如果没有一样的则不会提示

你可能感兴趣的:(Android,干嘛的)