美文网首页Android开发Android开发经验谈Android技术知识
AutoCompleteTextView在 输入数据时可以出现提

AutoCompleteTextView在 输入数据时可以出现提

作者: android_Pie | 来源:发表于2020-03-10 16:09 被阅读0次
            //1.获得AutoCompleteTextView
            AutoCompleteTextView at=(AutoCompleteTextView) findViewById(R.id.att);
            at.setThreshold(1);//设置输入几个字符长度便于出现提示文本
            //2.构建Adapter
            ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, 
            new String[]{"KK","JJJ","GGG","DDD","YYYY2020"});
            //3.关联Adapter
            at.setAdapter(adapter);
    
          布局如下   
          <AutoCompleteTextView
            android:id="@+id/att"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="please input" />
    
    

    相关文章

      网友评论

        本文标题:AutoCompleteTextView在 输入数据时可以出现提

        本文链接:https://www.haomeiwen.com/subject/vizwdhtx.html