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 ...
随机推荐
- HTML学习体会
HTML介绍 华丽的网页界面,都是由静态网页和一些动态效果,插入的视频,和flash等等,不得不说,静态网页的制作,是学习网页的必经之路,可见静态网页在学习网页的前端是十分重要.静态网页主要是通过ht ...
- Java线程操作方法
取得和设置线程名称 //================================================= // File Name : Thread_demo //--------- ...
- c++模板类
c++模板类 理解编译器的编译模板过程 如何组织编写模板程序 前言常遇到询问使用模板到底是否容易的问题,我的回答是:“模板的使用是容易的,但组织编写却不容易”.看看我们几乎每天都能遇到的模板类吧,如S ...
- 微型orm fluentdata
http://fluentdata.codeplex.com/documentation#Query
- SCWS分词扩展在UNIX/LINUX下的安装方法
<?php/** * 中文分词处理方法 *+--------------------------------- * @param stirng $string 要处理的字符串 * @param ...
- Python之路【第九篇】堡垒机基础&数据库操作
复习paramiko模块 Python的paramiko模块,是基于SSH用于连接远程服务器并执行相关操作. SSHClient #!/usr/bin/env python #-*- coding:u ...
- NSURLSession & NSCache
用于替代 NSURLConnection 支持后台运行的网络任务 暂停.停止.重启网络任务,不再需要 NSOperation 封装 请求可以使用同样的配置容器 不同的 session 可以使用不同的私 ...
- H5 使用
关闭页面 http://www.bcty365.com/content-146-3343-1.html 回退页面: plus.key.addEventListener('backbutton', fu ...
- 【转】常用的shell脚本
from:http://blog.sina.com.cn/s/blog_4152a9f501013r6c.html 常用的shell脚本 (2012-10-10 22:09:07) 转载▼ 标签: 杂 ...
- asp.net mvc 实现博客的时间分类管理
先看效果 这个其实用c#实现起来比较简单: Sides = bllSession.IArticleBLL.GetList("") .Select(a => a.Time) . ...