The Adapter of ListView: Just adapt data to view, don’t do anything else
The design of SimpleAdapter is not good in my opinion.
An adapter should just adapter the data to view, not care to inflate xml to create Layout View, hold the member Views of the layout view, and, fill the datas to each member View one by one. SimpleAdapter does these things all together. It is high coupling design.
The solution is a ItemViewHolder class, which inflate and hold the layout view and its member views, and parse datas to fill them to member views one by one. And the most cool is, it’s layout view of ItemViewHolder set “this” as its tag. So that you can get the ItemViewHolder instance of the convertView in getView(…, View convertView, …) function.
See below code snippets.
In Adapter, passed in a List as data list.
1 |
List<Data> dataList; |
and override getView() like this:
1 |
@Override |
ItemViewHolder is the views holder of the convertView.
1 |
public class ItemViewHolder {
//The layout View of the item of the ListView.
|
The Adapter of ListView: Just adapt data to view, don’t do anything else的更多相关文章
- 使用自定的Adapter绑定ListView/GridView数据
使用自定的Adapter绑定ListView/GridView数据(地址) 对于ListView/Gridview的数据绑定, google提供了一些Adapter的模板, 自己也可以自定义一些个性化 ...
- 【转】Android自定义Adapter的ListView的思路及代码
原文网址:http://www.jb51.net/article/37236.htm Android自定义Adapter的ListView的思路及代码,需要的朋友可以参考一下 在开发中,我们经常使 ...
- 【转载】逃离adapter的地狱-针对多个View type的组合实现方案
英文原文:JOE'S GREAT ADAPTER HELL ESCAPE 转载地址:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015 ...
- iphone dev 入门实例2:Pass Data Between View Controllers using segue
Assigning View Controller Class In the first tutorial, we simply create a view controller that serve ...
- 关于自定义Adapter实现ListView的使用
以下为使用BaseAdapter作扩展,自定义Adapter来使用ListView控件: 需要注意以下的几点: 1.自定义Adapter时,需要特别注意Adapter类中getView()方法覆盖,注 ...
- Android学习----自定义Adapter实现ListView
前言: 对于ListView而言,自定义的Adapter对于显示复杂的界面有很大的灵活性 .使用自定义的Adapter需要继承BaseAdapter,然后重写getCount(),getView(), ...
- Android 自定义Adapter 但listview 只显示第一条数据
<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content ...
- 【转】Android之自定义Adapter的ListView
http://www.cnblogs.com/topcoderliu/archive/2011/05/07/2039862.html 在开发中,我们经常使用到ListView这个控件.Android的 ...
- Android之自定义Adapter的ListView
ListView的创建,一般要具备两大元素: 1)数据集,即要映射的字符串.图片信息之类. 2)适配器,实现把要映射的字符串.图片信息映射成视图(如Textview.Image等组件),再添加到Lis ...
随机推荐
- Runner站立会议08
会议时间:2016.4.27 21.10~21.25 地点:基教负一层 今天:看日历的代码,网上下的,没有注释 明天:继续看代码 困难:代码看不懂 会议照片: 燃尽图:
- Windows Platform Predefined Macros
https://msdn.microsoft.com/en-us/library/b0084kay.aspx
- ecshop添加上传图片
基础 cls_images.php: function upload_image(){} $_FILES 输出值:Array ( [group_thumb_url] => Array ( [n ...
- Redis-cluster集群【第四篇】:redis-cluster集群配置
Redis分片: 为什么要分片:随着Redis存储的数据越来越庞大,会导致Redis的性能越来越差! 目前分片的方法: 1.客户端分片 在应用层面分片,程序里指定什么数据存放在那个Redis 优势: ...
- haproxy配置文件
haproxy配置文件 思路:读一行.写一行 global log 127.0.0.1 local2 daemon maxconn 256 log 127.0.0.1 local2 info de ...
- java String 中 intern方法的概念
1. 首先String不属于8种基本数据类型,String是一个对象. 因为对象的默认值是null,所以String的默认值也是null:但它又是一种特殊的对象,有其它对象没有的一些特性. 2. ne ...
- SQL语句学习笔记
从外部EXCEl文件导入sqlserver数据库操作命令 reconfigure reconfigure go select * into abc1_1 from OPENROWSET('MICROS ...
- php操作mysql数据库
<span style="font-family:Arial,Helvetica,sans-serif">在php操作数据库过,会频繁对数据库进行各种操作,所以,php ...
- 2015年12月10日 spring初级知识讲解(二)最小化Spring XML配置 注解
序,随着Spring容器管理Bean数量增加,XML文件会越来越大,而且纯手工配置XML很繁琐,Spring和JAVA都提供了一些注解方式用以简化XML配置. 目录 一.自动装配(autowiring ...
- 湖南附中模拟day1 瞭望塔
/* 这个题要用到树的性质,一般比较难的图论题会往这方面靠拢,这样用很容易出错,应该先写暴力,然后再去一点点想正解 */ //暴力70分 #include<iostream> #inclu ...