Android的适配器
//====================ArrayAdapter===================================
public class List1 extends Activity {
private ListVeiw listView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listView=new ListVeiw(this);
listView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, mStrings));
setContentVieww(listView);
}
private String[] mStrings = {
"Abbaye de Belloc", "Abbaye du Mont des Cats",
"Acorn", "Adelost", "Affidelice au Chablis",
"Aisy Cendre", "Allgauer Emmentaler", "Alverca",
"Ami du Chambertin", "Anejo Enchilado", "Anneau
"Aragon", "Ardi Gasna", "Ardrahan", "Armenian
"Asadero", "Asiago", "Aubisque Pyrenees", "Autun",
"Babybel", "Baguette Laonnaise", "Bakers", "Bal"};
}
//=============================SimpleAdapter==========================
public class List3 extends ListActivity {
List<Map<String, Object>> list;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
list = getListForSimpleAdapter(); //list为数据集合
SimpleAdapter adapter = new SimpleAdapter(this, list,
R.layout.item,
new String[] { "BigText", "LittleText", "img" },
new int[] { R.id.BigText,R.id.LittleText, R.id.img });
//可以想成把一个放好数据的布局文件放入本界面中
setListAdapter(adapter);
}
private List<Map<String, Object>> getListForSimpleAdapter() {
List<Map<String,Object>> list=newArrayList<Map<String, Object>>(3);
Map<String, Object> map = new HashMap<String, Object>();
map.put("BigText", "Android");
map.put("LittleText", "Google phone.");
map.put("img", R.drawable.n);
list.add(map);
map = new HashMap<String, Object>();
map.put("BigText", "Lenovo");
map.put("LittleText", "Ophone");
map.put("img", R.drawable.o);
list.add(map);
map = new HashMap<String, Object>();
map.put("BigText", "Droid");
map.put("LittleText", "Motorola");
map.put("img", R.drawable.droid);
list.add(map);
return list;
}
}
Android的适配器的更多相关文章
- Android进阶笔记10:Android 万能适配器
1. Android 万能适配器 项目中Listview GridView几乎是必用的组件,Android也提供一套机制,为这些控件绑定数据,那就是Adapter.用起来虽然还不错,但每次都 ...
- [置顶] Android常用适配器控件
Android常用适配器控件 列表控件用于显示数据集合,Android不是使用一种类型的控件管理显示和数据,而是将这两项功能分布用列表控件和适配器来实现.列表控件扩展了android.widget.A ...
- Android进阶笔记09:Android 万能适配器
1. Android 万能适配器 项目中Listview GridView几乎是必用的组件,Android也提供一套机制,为这些控件绑定数据,那就是Adapter.用起来虽然还不错,但每次都 ...
- Android adapter适配器的学习
学习Android有一点时间,说说自己的学习感悟. 首先呢,先说说适配器的作用,顾名思义,它就是把数据定义好一定的规则,使得我们可以用到ListView GridView等上面 所以说这玩意,还是得好 ...
- android各种适配器的用法(转)
ArrayAdapter_SimpleAdapter_CursorAdapter的区别 数据源不同而已1. String[]: ArrayAdapter2. List<Map<String ...
- Android adapter适配器的使用
说起Adapter的使用,首先想到的就是listview或各种各样的Adapter.下面我们对常用的一些Adapter进行简单的使用讲解. 这是Adapter的关系图: 下面的所有例子均使用同一个布局 ...
- Android 数据适配器
把复杂的数据(数组.链表.数据库.集合等)填充到指定的视图界面上. arrayAdapter(数组适配器): 用于绑定一些格式单一的数据,数据源:数据或者集合. private Li ...
- Android万能适配器Adapter-android学习之旅(74)
万能适配器的代码的github地址是https://github.com/fengsehng/CommonAdapter 万能适配器的代码的github地址是https://github.com/fe ...
- 【原创】Android自定义适配器的使用方法
比如说我们已经得到了数据,想在一个listview或者在其他的控件中显示的,并且我们显示想要自己设计样式来显示的话就要用到自定义适配器了,下面让我们结合代码讲一下具体的使用方法: 代码会有注释的哦: ...
- Android 简单适配器(SimpleAdapter)
1.介绍 2.简单适配器的实现方法 3.XML文件 (1)主页面布局 <?xml version="1.0" encoding="utf-8"?> ...
随机推荐
- Sql server中内连接语句
数据库中学生表和课程表如下: 内连接sql语句: select a.studentName,a.studentAge,b.courseName from student a inner join co ...
- Windows下使用Git和GitHub.com
1.首先介绍一下什么是Git和GitHub Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理.在推出后,Git在其它项目中也取得了很大 ...
- SET Statements (Transact-SQL)
The Transact-SQL programming language provides several SET statements that change the current sessio ...
- 如何在 Linux 中清除缓存(Cache)
如何在 Linux 中清除缓存(Cache) 方法一: http://mp.weixin.qq.com/s?__biz=MjM5ODAzODgyMQ==&am ...
- [BS-12] JSON的基础知识--百科
JSON的基础知识--百科 http://baike.baidu.com/view/136475.htm
- IntelliJ IDEA 修改缓存文件设置
今天在查看C盘,发现虽然我idea安装在了D盘,但是idea的缓存还是在C盘 config 目录是 IntelliJ IDEA 个性化化配置目录,或者说是整个 IDE 设置目录.也是我个人认为最重要的 ...
- VMWare虚拟机下为Ubuntu 12.04.1配置静态IP_转
转自:http://www.cnblogs.com/objectorl/archive/2012/09/27/vmware-ubuntu-nat-static-ip-settings.html 背景在 ...
- lib3ds类库
lib3ds类库 /* * The 3D Studio File Format Library * Copyright (C) 1996-2007 by Jan Eric Kyprianidis &l ...
- nsstring字符串重组
// // main.m // 05-字符串重组 // // Created by apple on 14-3-20. // Copyright (c) 2014年 apple. All ri ...
- 一个NULL引发的血案
go sql.stmt query 发生了一个NULL值,所以发现了error, 发现服务不停的初始化sql stmt, 导致连接数过多,服务就变得很慢. 首先,我在初始化的之前,要判断这个是否是NU ...