您好,登录后才能下订单哦!
密码登录
            
            
            
            
        登录注册
            
            
            
        点击 登录注册 即表示同意《亿速云用户服务条款》
        AutoComlete TextView,即自动完成文本框,从EditText派生而出,它的本质上也是一个编辑框,比普通编辑框多了一个功能:当用户输入一定字符之后,自动完成文本框会显示下拉菜单,然用户选择是否需要点击某个菜单项
首先在xml中定义一个AutoComleteTextView
<AutoCompleteTextView android:id="@+id/auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionHint="请选择您喜欢的资源:" android:dropDownHorizontalOffset="10dp" android:completionThreshold="1"/>
然后继续定义一个Multi AutoComleteTextView, Multi AutoComleteTextView是 AutoComleteTextView的子项,这子项允许输入多个提示项
<MultiAutoCompleteTextView android:id="@+id/mauto" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionThreshold="1"/>
然后打开MainActivity
public class MainActivity extends Activity
{
 AutoCompleteTextView act;
 MultiAutoCompleteTextView mautv;
 String[] ts = new String[]{
   "itPub",
   "it研究",
   "itPUB",
   "it算法"
 };
 @Override
 public void onCreate(Bundle savedInstanceState)
 {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  ArrayAdapter<String> abc = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line, ts);
  act = (AutoCompleteTextView)findViewById(R.id.auto);
  act.setAdapter(abc);
  mautv = (MultiAutoCompleteTextView)findViewById(R.id.mauto);
  mautv.setAdapter(abc);
  mautv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
 }
}免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。