- 浏览: 2998121 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (893)
- android (110)
- iphone (198)
- java (79)
- JavaScript手册-目录 (9)
- JavaScript手册-Array (19)
- JavaScript手册-Boolean (5)
- JavaScript手册-Date (50)
- JavaScript手册-Math (30)
- JavaScript手册-Number (14)
- JavaScript手册-RegExp (7)
- JavaScript手册-String (38)
- JavaScript手册-全局函数 (8)
- JavaScript实用脚本 (7)
- Others (21)
- java-jpcap (7)
- java-thread (1)
- ibm文章 (3)
- classloader (2)
- java-filter (2)
- 运行环境 (33)
- java-正则 (2)
- oracle (1)
- linux-shell (26)
- wap (1)
- sqlite (3)
- wow (1)
- jvm (1)
- git (5)
- unity3d (29)
- iap (2)
- mysql (23)
- nginx (14)
- tomcat (9)
- apache (2)
- php (1)
- ubuntu (40)
- rsa (1)
- golang (21)
- appstore (5)
- sftp (2)
- log4j (2)
- netty (18)
- 测试工具 (6)
- memcache (5)
- 设计模式 (1)
- centos (8)
- google_iab (5)
- iOS专题 (4)
- mac (10)
- 安装配置帮助手册 (2)
- im4java_graphicsmagick (5)
- inotify-tools (1)
- erlang (6)
- 微信支付 (1)
- redis (8)
- RabbitMQ (5)
最新评论
-
heng123:
Netty视频教程https://www.douban.com ...
netty4.0.23 初学的demo -
maotou1988:
使用Netty进行Android与Server端通信实现文字发 ...
netty4.0.23 初学的demo -
码革裹尸:
非常感谢,正好用上
android 呼入电话的监听(来电监听) -
rigou:
提示的/222.177.4.242 无法链接到ip地址,是什 ...
通过 itms:services://? 在线安装ipa ,跨过app-store -
duwanbo:
GridView与数据绑定
1个简单的SimpleAdapter工具类-SimpleAdapterUtil
根据android.widget.SimpleAdapter来生成对应需要装备的适配器。
代码:
版本一:数据格式为List<Object[]>
package com.zhouzijing.android.util; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import android.content.Context; import android.widget.SimpleAdapter; public class SimpleAdapterUtil{ /** * 创建适配器并配置数据. * @param context The context where the View associated with this SimpleAdapter is running * @param item 需要绑定的数据 * @param resource resource Resource identifier of a view layout that defines the views for this list * item. The layout file should include at least those named views defined in "to" * @param to The views that should display column in the "from" parameter. These should all be * TextViews. The first N views in this list are given the values of the first N columns * in the from parameter. * @return */ public static SimpleAdapter create(Context context,List<Object[]> item, int resource,int[] to) { //定义适配器内容数据 List<Map<String,?>> data = new ArrayList<Map<String,?>>(); //获取要显示内容数量 int itemLength = item.get(0).length; //获取要显示内容内部长度 int itemCount = item.size(); //定义适配器from参数 String[] adapterFroms = new String[itemCount]; for(int i=0;i<itemCount;i++){ adapterFroms[i]="Item"+String.valueOf(i); } //准备适配器内容 for(int i=0;i<itemLength;i++){ Map<String,Object> map = new HashMap<String,Object>(); for(int j=0;j<itemCount;j++){ map.put(adapterFroms[j], item.get(j)[i]); } data.add(map); } //绑定适配器并返回 SimpleAdapter simpleAdapter = new SimpleAdapter(context, data, resource, adapterFroms, to); return simpleAdapter; } }
版本二:数据格式为ArrayList<ArrayList<Object>>
package com.zhouzijing.android.util; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import android.content.Context; import android.widget.SimpleAdapter; public class SimpleAdapterUtil{ /** * 创建适配器并配置数据. * @param context The context where the View associated with this SimpleAdapter is running * @param item 需要绑定的数据 * @param resource resource Resource identifier of a view layout that defines the views for this list * item. The layout file should include at least those named views defined in "to" * @param to The views that should display column in the "from" parameter. These should all be * TextViews. The first N views in this list are given the values of the first N columns * in the from parameter. * @return */ public static SimpleAdapter create(Context context,ArrayList<ArrayList<Object>> item, int resource,int[] to) { //定义适配器内容数据 List<Map<String,?>> data = new ArrayList<Map<String,?>>(); //获取要显示内容数量 int itemLength = item.get(0).size(); //获取要显示内容内部长度 int itemCount = item.size(); //定义适配器from参数 String[] adapterFroms = new String[itemCount]; for(int i=0;i<itemCount;i++){ adapterFroms[i]="Item"+String.valueOf(i); } //准备适配器内容 for(int i=0;i<itemLength;i++){ Map<String,Object> map = new HashMap<String,Object>(); for(int j=0;j<itemCount;j++){ map.put(adapterFroms[j], item.get(j).get(i)); } data.add(map); } //绑定适配器并返回 SimpleAdapter simpleAdapter = new SimpleAdapter(context, data, resource, adapterFroms, to); return simpleAdapter; } }
发表评论
-
Android Fragment 真正的完全解析(下)
2015-03-25 14:30 1122Android Fragment 真正 ... -
Android Fragment 真正的完全解析(上)
2015-03-25 10:14 912Android Fragment 真正的 ... -
Activity的生命周期方法
2015-03-25 09:54 580一:Activity的生命周期方法 Android ... -
Android在layout xml中使用include
2015-03-25 07:28 998在Android的layout样式定义中,可以使 ... -
一个支持圆角的快速ImageView:RoundedImageView
2015-03-07 09:50 11093一个支持圆角的快速ImageView:Rounded ... -
ImageView图片设置
2015-03-05 23:08 957显示任意图像,例如图标。ImageView类可以加载 ... -
ListActivity的onListItemClick不响应的解决办法
2015-03-04 17:57 1108ListActivity的onListItemClic ... -
ListView中有控件隐藏或显示造成的显示错误问题
2015-03-03 23:03 1853ListView中有控件隐藏或显示造成的显示错误问题 ... -
Android中Application类用法
2015-03-03 09:12 998Android中Application类用法 ... -
Android使用Application总结
2015-03-03 09:11 1196Android使用Application ... -
在android中运行java main方法
2015-02-27 10:38 999在android中运行java main方法 ... -
android BitmapFactory.Options
2015-02-19 21:01 1036public Bitmap inBi ... -
android 基础demo例子
2015-02-16 21:06 836demoDatas.add(new DemoBe ... -
Android大图片裁剪终极解决方案
2015-02-15 17:08 2165Android大图片裁剪终 ... -
Android_照相机Camera_调用系统照相机返回data为空
2015-02-15 14:17 1294Android_照相机Camera_调用系统照相机返回 ... -
Android: 打印Bundle内容
2015-02-15 14:11 2967Android: 打印Bundle内容 有的时 ... -
android线程、UI、AsyncTask
2015-02-13 18:06 1287本文是转摘的,看过了觉得很好!所以转了过来!如果你想要 ... -
Fragment中ListView的使用
2015-02-06 23:01 2127Fragment中ListView的使用 直接 ... -
在安卓开发时用酷派手机无法打印出应用内的日志的解决方法
2014-12-11 20:39 1200在安卓开发时用酷派手机无法打印出应用内的日志的解决方法 ... -
查看安卓APK文件证书的方法
2014-12-04 10:05 1011************************** ...
相关推荐
ES注解工具类-002-update
不需要关心接受的字符串编码是UTF_8还是GBK,还是ios-8859-1,自动转换为utf-8编码格式,无需判断字符串原有编码,用法://处理编码String newStr = GetEncode.transcode(oldStr);
DataUtil--数据工具类--数据类型判断和比较,包括判断字符串是否为空,判断字符串不为空,判断是否为数字,判断是否为整型数字,判断是否为日期字符串(格式如:2014-04-01),判断是否为时间字符串(格式如:2014-...
IpUtil工具类--通过request获取IP,通过IP获取地址(需要联网,调用淘宝的IP库)。使用场景:在网站开发记录用户增删改查日志的时候,往往需要记录操作人的IP地址,来准确的生成操作日志记录等
3、该工具类使用非常简单。只需要复制数据库列名,支持多列复制,执行工具类即可生成对应的Java字段代码。 4、优点:使用代码生成驼峰形式的字段,可以减少出错概率,生成的实体类字段符合Java命名规范,易于阅读...
对象与对象转换工具类-就Javabean
精心整理的java常用的26个工具类 下载精心整理的java常用的26个工具类 下载精心整理的java常用的26个工具类 下载精心整理的java常用的26个工具类 下载精心整理的java常用的26个工具类 下载精心整理的java常用的26个...
本案例中的"工具类-获取访问ip地址工具类,自用留存"是一个专门用于获取网络访问IP地址的Java工具类。这个工具类可能包含了一些方法,用于在不同的网络环境中准确地获取到客户端的IP地址,这对于网络应用的统计分析...
VIN码校验工具类-Java语言
微信小程序开发-工具类-画布:时钟案例源码.zip
JD-GUI是一个图形化的Java反编译工具,它可以将.dex文件中的字节码转换回可读的Java源代码。以下是使用JD-GUI进行APK反编译的基本步骤: 1. **下载与安装JD-GUI**:下载压缩包中的jd-gui-windows-1.6.6,解压后运行...
使用阿里云OSS对象存储服务,根据SDK编写文件上传、下载、查询、删除、获取文件链接、创建文件夹等方法的工具类Util,该工具类已在正式应用环境中经受考验,其中有示例demo使用方法教程,方法有注解,帮助使用者更好...
这个压缩包"swift-集成OBJC中几乎所有的分类工具类拖进你的项目即时即用"提供了一个名为"CLObjcSugar-master"的资源,它很可能包含了一系列Objective-C编写的分类工具类,旨在帮助Swift开发者快速便捷地在项目中集成...
以下是对"Android-简单的Android工具类包含ActivityFragmentApplication基类和各类常用工具类集合"这个主题的详细解析。 1. **Activity基类**: - Activity基类通常包含一些通用的方法,如初始化布局、处理权限、...
开发工具 aspectjweaver-1.8.4开发工具 aspectjweaver-1.8.4开发工具 aspectjweaver-1.8.4开发工具 aspectjweaver-1.8.4开发工具 aspectjweaver-1.8.4开发工具 aspectjweaver-1.8.4开发工具 aspectjweaver-1.8.4开发...
[工具类] 一个压缩工具类.java.txt [工具类] 用java编写简单UDP网络通信程序 .java.txt [工具类] 中文验证.jsp.txt [工具类] 日期DateUtil.java [工具类] 文件FileUtil.java [工具类] 通信客户端simpleClient.java ...
总之,这个压缩包提供了一个为View添加阴影效果的工具类,尽管可能存在兼容性和适用性的问题,但它仍然是一个宝贵的参考资料,有助于开发者学习如何在Android应用中创建丰富的视觉效果。通过实践和学习,开发者可以...
本人工作中自己写的一个excel工具类,可以单独打包成jar,作为公共模块使用。 使用它可以直接不用关心poi的api。导入导出,轻轻松松。 使用方法请关注一下,cn.com.flaginfo.biz.excel.test 包下面的Test类。
easypoi实现上百万大数据导出excel工具,需要引入3.0.1版本easypoi相关依赖即可,该工具类也提供自定义动态标题,动态填充数据实现导出数据功能(但此功能最大导出为6w,导出大数据请用工具中的另一个方法,亲测有效...
RSA非对称加密工具类 用于网络传输中数据加密