android自带记录功能的输入框AutoCompleteTextView

 

                                     

使用环境:

        需要用到提醒输入功能的输入框时使用

使用效果:

               

使用方法:

AutoCompleteTextView

1 xml布局:

     <AutoCompleteTextView
            android:id="@+id/search"
            android:layout_width="@dimen/threehundred"
            android:layout_height="@dimen/thirtyfive"
            android:layout_marginLeft="@dimen/eight"
            android:layout_marginTop="@dimen/twenty"
            android:background="@drawable/draw_fragment_message_vin"
            android:drawablePadding="8dp"
            android:hint="@string/input_search_info_vin"
            android:inputType="text"
            android:maxLength="17"
            android:maxLines="1"
            android:completionThreshold="1"
            android:paddingLeft="@dimen/fifteen"
            android:textColor="@color/tv_1"
            android:textColorHint="@color/tv_3"
            android:textSize="@dimen/textsize12" />
android:completionThreshold="1"意思: 输入一个字符就开始做筛选

2 代码中调用:

    String[] autoString = new String[]{"LGBG22E00EY201241", "LGBG22E00EY201242",
                "LGBG22E00EY201243", "LGBG22E00EY201244", "LGBG22E00EY201245",
                "LGBG22E00EY201246", "LGBG22E00EY201247",
                "LGBG22E00EY201248", "LGBG22E00EY201249"};
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
                R.layout.simple_dropdown_item_1line, autoString);
        binding.search.setAdapter(adapter);

 

 

 MultiAutoCompleteTextView

 支持多个关键词,用“  ,  ” 隔开搜索的输入框:

<MultiAutoCompleteTextView  
        android:id="@+id/multiAutoCompleteTextView"  
        android:layout_width="fill_parent"  
        android:layout_height="wrap_content" /> 

代码中调用与上边一样即可。

有问题需要讨论请加QQ: 88627109

欢迎您的光临

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值