SimpleAdapter ArrayAdapter用法
2024-09-30 06:31:17
listView = (ListView) findViewById(R.id.list_main); /* String[] strings = {"A","A","A","A","A","A","A","A","A"}; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_ctn, strings);*/ List<Map<String, Object>> arrayList = new ArrayList<Map<String, Object>>(); Map<String, Object> map = null; int i = 0; while (i<10) { map = new HashMap<String, Object>(); map.put("name", "zh"+i); map.put("age", i); arrayList.add(map); i++; } String[] from = {"name", "age"}; int[] to = {R.id.list_ctn_name, R.id.list_ctn_age}; SimpleAdapter adapter = new SimpleAdapter(this, arrayList, R.layout.list_ctn, from, to); listView.setAdapter(adapter);
<ListView android:id="@+id/list_main" android:layout_width="match_parent" android:layout_height="match_parent" />
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/list_ctn_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="TextView" /> <TextView android:id="@+id/list_ctn_age" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="TextView" /> </LinearLayout>
最新文章
- FPGA中的delay与latency
- JavaScript parseInt函数
- CXF 入门:创建一个基于WS-Security标准的安全验证(CXF回调函数使用,)
- Scrum会议2(Beta版本)
- iOS - UITabBarController
- Oracle EBS 如何月结、对账[Z]
- 汽车Vin码识别——&#160;一款二手车行业值得拥有的OCR识别软件
- JavaScript面向对象深入理解原型
- Python内置函数(46)——oct
- sitecore开发入门教程如何获取Sitecore项目的域名
- Android各国语言对照表(values-xxx)
- springBoot_freemark配置
- 在python pydev中使用todo标注任务
- rest_framework_api规范
- jpa多条件查询重写Specification的toPredicate方法(转)
- uboot中CMD的实现
- yii的一些方法的解析和blog的详细解析
- Replication--复制与CDC和镜像
- Socket、RPC通信实例,简单版本,仅供查阅
- SCI 美国《科学引文索引》(Science Citation Index, 简称 SCI )
热门文章
- [TJOI2009]开关 (线段树)
- Cstring中GetBuffer()方法的主要作用
- Linux(7):用户管理
- 染色(bzoj 2243)
- 记录一下 ps命令找出线程占用cpu情况
- centos7 安装teamviewer 报错libQt5WebKitWidgets.so.5()(64bit)
- windows下模拟linux命令的工具 xshell
- Chrome 浏览器安装Vue插件方法 (十分详细)
- 解决Linux系统没有/etc/sysconfig/iptables文件
- poj 2135 Farm Tour 最小费最大流