下面介绍下SimpleAdapter的相关知识
以下是官方网上对SimpleAdapter的介绍:
An easy adapter to map static data to views defined in an XML file. You can
specify the data backing the list as an ArrayList of Maps.
Each entry in the ArrayList corresponds to one row in the list. The Maps contain the data for each row. You also specify an XML file that defines the views used to display the row, and a mapping from keys in the Map to specific views.
Binding data to views occurs in two phases.
First, if a SimpleAdapter.ViewBinder is available, setViewValue(android.view.View, Object, String) is invoked.
If the returned value is true, binding has occurred.
If the returned value is false, the following views are then tried in order:
(1)A view that implements Checkable (e.g. CheckBox). The expected bind value is a boolean.
(2)TextView. The expected bind value is a string and setViewText(TextView, String) is invoked.
(3)ImageView. The expected bind value is a resource id or a string and setViewImage(ImageView, int) or setViewImage(ImageView, String) is invoked.
If no appropriate binding can be found, an IllegalStateException is thrown.
(大概中文解释:适配器,将静态数据映射到在xml文件中定义的视图上,指定数据列表。每个ArrayList中得一项对应在ListView中的一行。你能自定一个Layout布局文件通过关键字映射来显示数据。
绑定数据分为两个阶段:
首先,如果一个SimpleAdapter.ViewBinder是有效的,setViewValue(android.view.View, Object, String)将被调用;
否则,如果返回失败,则会尝试以下的几个步骤。。。。。)
上代码
注2:
public SimpleAdapter (Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to)
参数
context 关联SimpleAdapter运行着的视图的上下文。
data 一个Map的列表。在列表中的每个条目对应列表中的一行,应该包含所有在from中指定的条目
resource 一个定义列表项目的视图布局的资源唯一标识。布局文件将至少应包含哪些在to中定义了的名称。
from 一个将被添加到Map上关联每一个项目的列名称的列表
to 应该在参数from显示列的视图。这些应该全是TextView。在列表中最初的N视图是从参数from中最初的N列获取的值。
注3:
显示数据,通过getDropDownView获取要显示的数据。。。。
list_item.xml(ListView每个Item显示布局)
有问题请留言。。。谢谢。。。
联系方式:ligexiao@gmail.com
分享到:
相关推荐
【Android开发学习28】界面控件之列表控件(ListView)--显示字符数组
【Android开发学习29】界面控件之列表控件(ListView)--显示图片和文本 代码
Android--开发--下拉刷新控件(ListView好ScrollView版)
NULL 博文链接:https://androidtoast.iteye.com/blog/1166433
本节主要介绍Android开发过程中的复杂控件,及ListView控件,可以支持同学们做一些新闻类、信息类应用的开发.
1、Android01--搭建Android开发环境 2、Android02--认识Activity 3、Android03--Context和Application 4、Android04--Android服务 5、Android05--Android服务通信 6、Android06--Android广播接收器 7、Android07--...
ListView空间的基本用法,对于开发人员适用
很好的Delphi Firemonkey控件,可用作Android、iOS、MacOS、Windows开发,比Delphi自带的listview更好用、功能更强大! ListView1.SetColorItemSelected(TAlphaColorRec.Orangered); ListView1.SetColorItemFill...
自定义控件实现listview的滑动删除item
滑动listview标题置顶,listview吸顶效果,安卓系统状态栏透明,有图有源码
在安卓APP开发过程中,ListView是常用的数据展示控件,不过系统自带的样式过于单调,而且显示数据单一。下面介绍一个卡片式的ListView控件。同样是经过测试,拿来主义,根据步骤一步步就能实现。 首先总体介绍一下...
在android应用开发过程中,Listview 是常用的数据展现控件,往往用于显示列表形式的数据。
android 常用控件如:ProgressBar、ActionBar、Switch、ListView 、PopupWindow....等的用法,各种Style的写法以及自定义常用控件 android 五大布局的汇总及用法
Android应用源码开发Demo,主要用于毕业设计学习。
Android控件ListView的使用及优化技巧.pdf
详细介绍了android开发中的listview控件的使用
Android应用源码开发Demo,主要用于毕业设计学习。
本文实例讲述了Android控件之ListView用法。分享给大家供大家参考。具体如下: 示例一: 在android开发中ListView是比较常用的组件,它以列表的形式展示具体内容,并且能够根据数据的长度自适应显示。 main.xml布局...
android listview的使用方法,创建listview列表,android开发控件的使用方法
android控件的抖动效果 很漂亮的ListView android 图像处理滤镜 照亮边缘特效 无闪烁启动画面 Android实现《天女散花》效果--(带源码) 天天动听 半透明Menu效果 Android 小項目之---Iphone拖动图片特效 (附源码) ...