[关闭]
@MasterLeng 2015-03-25T02:28:01.000000Z 字数 468 阅读 1246

SimpleAdapter使用

android开发 SimpleAdapter使用


平常在ListView适配器使用中,一般以继承BaseAdapter重写居多,的确是可以实现复杂的ListView布局,不过,当ListView的item相对固定的时候,可以考虑采取使用SimpleAdapter或者ArrayAdapter这两种轻量级的适配器。
SimpleAdapter使用起来非常简单,我们先来看一下SimpleAdapter的构造函数吧
SimpleAdapter simpleAdapter = new SimpleAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to);//取自官方文档
context毫无疑问是上下文,而List则是以Map为基本元素的数据集合,resouce则是item的布局文件,字符串数组则是由List里的Map中的所有的key组成的,而to则是Map里的value需要附加的组件组成的int数组。
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注