使用环境:
需要用到提醒输入功能的输入框时使用
使用效果:
使用方法:
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
欢迎您的光临