AutocompleteTextView内容补全有一个属性completionThreshold作用是输入最少几个字符进行提示package com.example.layou_text;importandroid.app.Activity;importandroid.os.Bundle;importandroid.widget.ArrayAdapter;importandroid.widget.AutoCompleteTextView;importandroid.widget.Spinner;publicclassChatnActivityextendsActivity{ Spinner spinner; AutoCompleteTextView auto; @Override protectedvoidonCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState); setContentView(R.layout.lv_man); spinner=(Spinner) findViewById(R.id.spinner);//下拉框auto=(AutoCompleteTextView) findViewById(R.id.auto);//提示框// 准备数据Stringdata[]={"502900588","17600446278","20141596"}; ArrayAdapter adapter =newArrayAdapter(this, android.R.layout.simple_spinner_item, data);//data必须是一个数组// ,data和.add只能有一个adapter.add("213");//不能添加数组只能是值//也可以在外面设置数据要通过adapter.add添加一个String的值adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);//设置点击跳出的布局,用了一个系统自带spinner.setAdapter(adapter);// Stringdataauto[]={"12345","1563731","2582381","2932414"}; ArrayAdapter adapter2 =newArrayAdapter(this, android.R.layout.simple_dropdown_item_1line ,dataauto); adapter2.notifyDataSetChanged();//更新列表auto.setAdapter(adapter2); }}布局.xml写下拉提示android:id="@+id/spinner"android:layout_width="match_parent"android:layout_height="wrap_content"布局写.xml自动提示android:id="@+id/auto"android:layout_width="match_parent"android:layout_height="wrap_content"android:completionThreshold="1"
网友评论