`
davice_li
  • 浏览: 90569 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

ListAdapter

阅读更多

也是ListAdapter 的直接子类。通过 SimpleAdapter 可以让 ListView 里面每一项的内容更加人性化,通常将 ListView 中某项的布局信心写在一个 XML 文件中。

SimpleAdapter的作用是作为 ArrayList ListView 的桥梁。需要注意的是,这个 ArrayList 里面的每一项都是一个 Map<String,?> 类型。

SimpleAdapter的构造函数:

public SimpleAdapter (Context context,List<? extends Map<String,?>>data,int resource,String[] from,int[] to)

其中:context: 上下文

data:基于 Map List

resource:就是一个 layout ,一般用系统的就可以了

From:这是一个名字的数组,每一个名字都是为了在 ArrayList 中每一个 item 中索引 Map<String,Object> Object 用的。

To:里边是一个 TextView 数组。这些 TextView 是以 id 的形式来表示的,如 android.R.id.text1.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics