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"?> ...
随机推荐
- 【转】Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用
Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用 分类: Android UI2015-06-15 16: ...
- Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree andsum =
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...
- NSUserDefaults 可以保存哪些类型
NSData NSString NSNumber NSDate NSArray NSDictionary *如果你想保存其他类型,如UIImage,你应该进行编码(即archive),或者将它转换为N ...
- CURL常用命令(转)
下载单个文件,默认将输出打印到标准输出中(STDOUT)中 curl http://www.centos.org 通过-o/-O选项保存下载的文件到指定的文件中:-o:将文件保存为命令行中指定的文件名 ...
- django工作原理
- SQLSERVER执行计划详解
序言 本篇主要目的有二: 1.看懂t-sql的执行计划,明白执行计划中的一些常识. 2.能够分析执行计划,找到优化sql性能的思路或方案. 如果你对sql查询优化的理解或常识不是很深入,那么推荐几骗博 ...
- Netty中BIO,NIO
同步阻塞io(BIO).伪异步io(PIO).非阻塞io(NIO).异步io(AIO)的概念及区别? 同步阻塞io(BIO):服务器端与客户端通过三次握手后建立连接,连接成功,双方通过I/O进行同步阻 ...
- UITableView + UISearchBar 实现搜索功能
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @pr ...
- [转]那些年我还不懂:IList,ICollection,IEnumerable,IEnumerator,IQueryable
1.首先看一个简单的例子 int[] myArray = { 1, 32, 43, 343 }; IEnumerator myie = myArray.GetEnumerator(); myie.Re ...
- Excel公式无法重算,暂无法解决
一份复杂的excel报表,某些单元格是用求和公式算出来的值,但生成之后,用excel打开,无法显示公式结果,按F9也没有用,只能在单元格公式双击后回车才会显示.而在WPS2010按F9就可以重算,WP ...