自动完成可编辑文本AutoCompleteTextView的使用
2012-09-04 23:42
316 查看
我们在百度或者Google中搜索信息所用的输入框,都是可以在我们输入少量文字的时候列出下拉菜单显示相关的搜索关键字,我们可以选择想要搜索的关键字而快速获取需要的信息。此功能即是使用了自动完成的可编辑文本输入框控件。在Android的UI开发中也有这样一个控件,它的名字叫AutoCompleteTextView,通过它我们可以实现类似搜索框那样的UI功能。
以下ATAAW.COM罗列下Android中的AutoCompleteTextView的具体使用方法。
A、在布局文件中的相应位置声明自动完成可编辑空间
<AutoCompleteTextView
android:id=”@+id/editText”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
/>
B、在程序中加载Android布局
setContentView(R.layout.autocompletetextview);
C、构造数据源,一般采用数组或者通过数据库获取数据源
private String[] ary = new String[] {
“ATAAW.COM”,
“随时随地”,
“即兴时代”,
“Android”,
“Google”,
};
D、通过数据源为空间创建适配器
ArrayAdapter<String> adapter = newArrayAdapter<String>(
this,
android.R.layout.simple_dropdown_item_1line,//这里使用的是Android自带的Style
ary);
E、为控件制定适配器
AutoCompleteTextView textView = (AutoCompleteTextView)findViewById(R.id.editText);
textView.setAdapter(adapter);
至此,一个自动完成的AutoCompleteTextView可编辑文本框完成了
以下ATAAW.COM罗列下Android中的AutoCompleteTextView的具体使用方法。
A、在布局文件中的相应位置声明自动完成可编辑空间
<AutoCompleteTextView
android:id=”@+id/editText”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
/>
B、在程序中加载Android布局
setContentView(R.layout.autocompletetextview);
C、构造数据源,一般采用数组或者通过数据库获取数据源
private String[] ary = new String[] {
“ATAAW.COM”,
“随时随地”,
“即兴时代”,
“Android”,
“Google”,
};
D、通过数据源为空间创建适配器
ArrayAdapter<String> adapter = newArrayAdapter<String>(
this,
android.R.layout.simple_dropdown_item_1line,//这里使用的是Android自带的Style
ary);
E、为控件制定适配器
AutoCompleteTextView textView = (AutoCompleteTextView)findViewById(R.id.editText);
textView.setAdapter(adapter);
至此,一个自动完成的AutoCompleteTextView可编辑文本框完成了
相关文章推荐
- 自动完成可编辑文本AutoCompleteTextView的使用
- 自动完成可编辑文本AutoCompleteTextView的使用
- Android UI系统控件进阶(三)—自动完成文本控件AutoCompleteTextView详解及属性
- AutoCompleteTextView 和 MultiAutoCompleteTextView 自动完成文本控件
- Android高级组件AutoCompleteTextView自动完成文本框使用详解
- MultiAutoCompleteTextView和AutoCompleteTextView两个自动完成功能控件的使用
- MultiAutoCompleteTextView和AutoCompleteTextView两个自动完成功能控件的使用
- MultiAutoCompleteTextView和AutoCompleteTextView两个自动完成功能控件的使用
- Android——适配器其他组件(AutoCompleteTextView:自动完成文本编辑框;Spinner:下拉列表)
- Android自动编辑文本框(AutoCompleteTextView)使用方法详解
- AutoCompleteTextView使用——自动完成文本框
- Android学习笔记(六)AutoCompleteTextView自动完成文本框
- Android开发高级组件之自动完成文本框(AutoCompleteTextView)用法示例【附源码下载】
- android 中使用AutoCompleteTextView 可以实现自动提示功能
- AutoCompleteTextView使用——自动完成文本框
- Android 高级UI组件之自动完成文本框(AutoCompleteTextView)
- Android组件系列(1):自动完成输入内容的组件(AutoCompleteTextView )
- 自动完成文本框AutoCompleteTextView(待解决)
- 高级控件之自动完成文本框(AutoCompleteTextView)
- Android练习-----自动完成文本框(AutoCompleteTextView)(搜索框)