SimpleAdapter ArrayAdapter用法
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>
SimpleAdapter ArrayAdapter用法的更多相关文章
- SimpleAdapter的用法
学习listView的时候,按照例子设定item的布局为系统提供的simple_list_item_single_choice.xml@frameworks/base/core/res/res/lay ...
- ArrayAdapter、SimpleAdapter简单用法
1. 使用流程 2. ArrayAdapter new ArrayAdapter<?>(context, textViewResourceId, objects) context:上下 ...
- BaseAdapter,SimpleAdapter,CursorAdapter的用法
简单好用的Adapter---ArrayAdapter ArrayAdapter是BaseAdapter的派生类,在BaseAdapter的基础上,添加了一项重大的功能:可以直接使用泛型构造. 我们先 ...
- ListView蛮好用
知识点如下: 1. ListView的基本用法 2. ArrayAdapter和SimpleAdapter的用法 3. OnScrollListener 和 OnItemClickListener 4 ...
- Android 自学之列表视图ListView和ListActivity
ListView是手机系统中使用非常广泛的一种组件,它以垂直列表的形式显示所有列表项. 创建ListView有两种方式: 直接使用ListView创建. 让Activity继承ListActivity ...
- 与数据库打交道的Adapter----SimpleCursorAdapter
http://www.cnblogs.com/wenjiang/p/3196486.html 程序员是这个世界上最神奇的职业,因为几乎所有其他职业的人都能转到该行来,只要他智力正常,有接受过正规的编程 ...
- android入门 — ListView
ListView主要是用来解决大量数据展示的问题,它的用途很广泛,几乎所有的app都会用到,比如说知乎.今日头条.微博.通讯录等. ListView允许用户通过上下滑动的方式将屏幕外的数据滚动到屏幕中 ...
- Android——ListView优化
1.ListView基本概念 列表显示需要三个元素: ListView:用来展示列表的View. 适配器:用来把数据映射到ListView上 数据:具体的将被映射的字符串,图片或基本组件 适配器类型分 ...
- 2015最新Android学习线路图
Android是一个以Linux为基础的半开源操作系统,主要用于移动设备,由Google和开放手持设备联盟开发与领导.据2011年初数据显示仅正式上市两年的操作系统Android已经跃居全球最受欢迎的 ...
随机推荐
- POJ 3581 Sequence ——后缀数组 最小表示法
[题目分析] 一见到题目,就有了一个显而易见obviously的想法.只需要每次找到倒过来最小的那一个字符串翻转就可以了. 然而事情并不是这样的,比如说505023这样一个字符串,如果翻转了成为320 ...
- 如何新建.htaccess文件
如何新建.htaccess文件 (1)新建文本文档,即txt文件: (2)把重写代码写进去: (3)然后选择[另存为],命名为.htaccess即可.
- Objective-C NSString的常用用法
//1.创建常量字符串. NSString *astring = @"This is a String!"; //2.创建空字符串,给予赋值. NSString *astrin ...
- Objective C语言中nil、Nil、NULL、NSNull的区别
以下内容是基于搜集整理的网上资料,供参考. nil:指向Objective C语言中对象的空指针,其定义值为(id)0. Nil:指向Objective C语言中类(Class)的空指针,其定义值为( ...
- Oracle 12c在SQL Devolper中添加cdb和pdb连接
Oracle 12c如果按默认流程安装的话会有一个叫orcl的cdb容器和一个叫pdborcld的pdb容器 一.连接名为orcl的cdb容器 连接名:localorcl 用户名:SYS 口令:Ora ...
- springboot启动报异常,Failed to load property source from location 'classpath:/application.yml'
学习springboot,在启动时抛出下图异常 往下看异常信息,找到异常的具体位置 找到application.yml文件的对应位置,发现params配置前面多了空格 去掉空格重新启动,可以了 写代码 ...
- 2018.11.6 PION 模拟赛
期望:100 + 40 + 50 = 190 实际:60 + 10 + 50 = 120 考得好炸啊!!T1数组开小了炸掉40,T2用 int 读入 long long ,int存储 long lon ...
- 74.Search in a 2D Matrix
/* * 74.Search in a 2D Matrix * 12.5 by Mingyang * 这里面的对应挺巧的: * 这个就是将2D矩阵转化成1行数组的对应表.所以对于二分查找法的初始值为: ...
- 【Lucene】具体解释Lucene全文检索的信息写入与读取
Lucene的大致结构图: 信息写入索引库的过程: 读取信息的过程: 以下是一个向索引库写入信息与读取信息的样例: public void testCreateIndex() throws Excep ...
- 用df命令显示磁盘使用量和占用率。
使用“df -k”命令,以k为单位显示磁盘使用量和占用率. root@gsg43:/tmp# df -kFilesystem 1K-blocks Used Available Use% ...