Android基础复习之Spinner
2015-09-22 08:52
369 查看
Android基础复习之Spinner
一.Spinner
1.父类:AbsSpinner->AdapterView 2.定义:下拉菜单控件 3.属性: spinnerMode 选项模式 dialog 对话框模式 dropdown 下拉模式 entries 下拉菜单列表的内容 一般都在代码中动态赋值 prompt 选项模式为对话框时,指对话框标题 popupBackground 下拉菜单列表的背景 dropDownWidth 下拉菜单列表的宽度 4.使用方法 1.创建一个数据源,数组或集合 2.使用ArrayAdapter构造器创建一个Adapter对象,构造器需要提供Spinner的外观布局及数据源 3.使用setDropDownViewResource方法为Spinner提供一个下拉菜单的布局 4.使用setAdapter()方法将创建好的Adapter对象设置进去 5.使用setOnItemSelectedLisnter()方法设置选择事件监听器 onItemSelected(AdapterView<?> parent, View view,int position, long id) onNothingSelected(AdapterView<?> parent)
二.ArrayAdapter
1.父类: BaseAdapter 2.定义: 数组类型适配器 3.作用:将指定的数据源显示到item选项布局中 4.构造方法: ArrayAdapter(Context context, int resource, List<T> objects) ArrayAdapter(Context context, int resource, T[] objects) 5.使用方法: setDropDownViewResource(int resource) 设置下拉列表布局资源 createFromResource(Context,int arrayId, int layoutId) 6.使用系统布局资源 android.R.layout.simple_list_item_single_choice android.R.layout_spinner_dropdown_item android.R.layout.simple_spinner_item android.R.layout_list_item_1
三.SimpleAdapter
1.定义: 简单数组适配器类,必须自定义选项item布局 2.父类: BaseAdapter 3.用法: SimpleAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) from:map中的key to:每个key要放的位置
四.AutoCompleteTextView
1.定义:自动提示的文本编辑控件 2.父类: EditText 3.常用属性: popupBackground 下拉菜单的背景 dropDownWidth 下拉菜单的宽度 completionThreshold 指定用户至少输入几个字符才会显示提示 textCursorDrawable="@null" 设置光标颜色与文本颜色一致 4.使用方法: 1.创建数据源:比如数组或集合 2.使用ArrayAdaper数组适配器设置下拉菜单布局及数据源 3.使用setAdapter()方法将ArrayAdapter对象加载到AutoCompleteTextView 4.使用addTextChangedListener(TextWatcher)方法设置控件的内容改变事件监听器 5.监听事件 addTextChangedListener (TextWatcher watcher) onTextChanged(CharSequence s, int start, int before, int count) beforeTextChanged(CharSequence s, int start, int count, int after) afterTextChanged(Editable s)
这是培训第4天的内容,记录以示复习
相关文章推荐
- Android Studio与Android SDK 在线更新的解决方案(1.3.2)
- android的多种对话框
- Android开发总结笔记 FrameLayout(帧布局) 1-1-3
- 半年之内拿下android
- android适配问题
- 源码分析Mms--AndroidManifest.xml分析
- android 画画
- 蜂窝教育Android培训:高薪等于开心吗?
- databinding学习(4)
- Getting Started: Configuring Mac for Android
- Android Activity生命周期详解
- AndroidStudio出现找不到JVM问题
- Android中Manifest的Application的name和getApplication()的关系
- Android studio中几个插件的使用
- Android Design Support Library 的 代码实验——几行代码,让你的 APP 变得花俏
- Android之JSON处理器FastJson
- Android之日期时间选择器使用方法
- [坑]android ListView 加载数据乱码
- Android获取手机及路由器的Mac地址和IP地址
- android 学习笔记1