Android基础TOP5_1:AutoCompleteTextView自动补全文本框


1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="match_parent"
 4     android:orientation="vertical"
 5     android:layout_height="match_parent"
 6     tools:context="com.example.top5_1.MainActivity" >
 7 
 8    <EditText
 9         android:layout_width="fill_parent"
10         android:layout_height="wrap_content"
11         android:paddingLeft="5dp"
12         android:background="#FFA500"
13         android:textSize="16sp"
14         android:drawableLeft="@drawable/ic_launcher"
15         android:text="单词搜索补全演示" />
16    <AutoCompleteTextView
17       android:id="@+id/ed"
18       android:layout_width="fill_parent"
19       android:layout_height="wrap_content"
20       style="@android:attr/textViewStyle"
21       android:hint="请输入单词"
//设置从第二个字符开始提示 22 android:completionThreshold="2" 23 android:layout_marginTop="10dp" 24 25 /></LinearLayout>

JAVA:

 1 public class MainActivity extends Activity{
 2 private AutoCompleteTextView act;
 3 //设置数据源
 4 private static final String[] words={"abc","acd","ade"};
 5 
 6 protected void onCreate(Bundle savedInstanceState) {
 7         super.onCreate(savedInstanceState);
 8         setContentView(R.layout.activity_main);
 9         act=(AutoCompleteTextView) findViewById(R.id.ed);
10         //将数据源赋到文本框
11     ArrayAdapter<String> aa=new ArrayAdapter<String>(this,
12             android.R.layout.simple_dropdown_item_1line,words);
13     act.setAdapter(aa);
14     };

优质内容筛选与推荐>>
1、python开头——文件声明 详解
2、前端面试题
3、理解C#值类型与引用类型
4、第三次作业
5、并不对劲的bzoj3626:loj2558:p4211:[LNOI2014]LCA


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn