Android为我们提供了android.widget.Adapter和android.widget.ExpandableListAdapter两大类数据适配器接口。
android.widget.ExpandableListAdapter接口主要和android.widget.ExpandableListView配合使用
而android.widget.Adapter接口主要和android.widget.AdapterView中android.widget.ExpandableListView之除外的其他类配合使用。
<wbr style="line-height:25px"><div style="line-height:25px">以下是<span style="line-height:22px"><strong>Adapter</strong><span style="line-height:22px">接口及子接口和实现类</span></span>的关系图</div>
<div style="line-height:25px"><span style="line-height:25px">图1:</span></div>
<div style="line-height:25px">
<div style="line-height:25px"><img alt="数据适配器简介(Adapter) - hubingforever - 民主与科学" src="http://img3.ph.126.net/Rb5A2rxb0Wjg1nd9AfD01g==/2607865659241250333.png" style="line-height:25px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; max-width:100%; margin-top:0px; margin-right:10px; margin-bottom:0px; margin-left:0px"></div>
</div>
publicinterface<span style="line-height:25px"><span style="color:#ff00ff; line-height:25px"><wbr style="line-height:25px">Adapter</wbr></span></span><wbr style="line-height:25px"><br style="line-height:25px"><span style="line-height:25px"><wbr style="line-height:25px">Adapter</wbr></span><wbr style="line-height:25px">是绑定Data和<a target="_blank" rel="nofollow" href="http://developer.android.com/reference/android/widget/AdapterView.html" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">AdapterView</a><wbr style="line-height:25px">的适配器<br style="line-height:25px">
实现<span style="line-height:25px"><wbr style="line-height:25px">Adapter</wbr></span><wbr style="line-height:25px">的直接接口有:<span style="color:#993300; line-height:25px">ListAdapter</span>和 <span style="color:#993300; line-height:25px"><wbr style="line-height:25px">SpinnerAdapter</wbr></span><wbr style="line-height:25px"><br style="line-height:25px">
更多可参考《<span style="line-height:24px; font-family:Arial,Helvetica,simsun,u5b8bu4f53; white-space:nowrap"><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/17104057920105113055538/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none; font-weight:bold">Adapter接口</a>》</span><br style="line-height:25px"><span style="line-height:25px">一、ListAdapter</span>
<div style="line-height:25px">
<span style="color:#ff00ff; line-height:25px">ListAdapter</span>是绑定Data和Listview的适配器。但是,它是接口,需要实现。<br style="line-height:25px">
实现了<span style="line-height:25px"><wbr style="line-height:25px">ListAdapter</wbr></span><wbr style="line-height:25px">的接口有:<br style="line-height:25px">
WrapperListAdapter<br style="line-height:25px">
实现<span style="line-height:25px"><wbr style="line-height:25px">ListAdapter</wbr></span><wbr style="line-height:25px">的类:<br style="line-height:25px"><span style="color:#993300; line-height:25px">BaseAdapter</span><br style="line-height:25px"><span style="color:#000080; line-height:25px"></span><span style="color:#0000ff; line-height:25px">ArrayAdapter<T><br style="line-height:25px">
CursorAdapter</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">ResourceCursorAdapter<br style="line-height:25px">
SimpleCursorAdapter</span><br style="line-height:25px"><span style="color:#000080; line-height:25px"> </span><span style="color:#0000ff; line-height:25px">SimpleAdapter</span><br style="line-height:25px"><span style="color:#993300; line-height:25px">HeaderViewListAdapter</span><span style="color:#000080; line-height:25px">(extendsObject)(implementsWrapperListAdapter)</span><br style="line-height:25px">
常见的有:arrayAdapter,SimpleAdapter,CursorAdapter。<br style="line-height:25px">
ListAdapter经常和ListView一起使用,具体可参考《ListActivity和ListView》<br style="line-height:25px"><span style="line-height:25px">二、<wbr style="line-height:25px">SpinnerAdapter</wbr></span><wbr style="line-height:25px"><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">SpinnerAdapter</span>是绑定Data和Spinner的适配器.<br style="line-height:25px">
它只申明了一个方法:<br style="line-height:25px">
abstract<a target="_blank" rel="nofollow" href="http://developer.android.com/reference/android/view/View.html" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">View</a><wbr style="line-height:25px"><br style="line-height:25px"><span style="line-height:1.3em"><a target="_blank" rel="nofollow" href="http://developer.android.com/reference/android/widget/SpinnerAdapter.html#getDropDownView%28int,%20android.view.View,%20android.view.ViewGroup%29" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">getDropDownView</a><wbr style="line-height:25px"></wbr></span><wbr style="line-height:25px">(intposition,<a target="_blank" rel="nofollow" href="http://developer.android.com/reference/android/view/View.html" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">View</a><wbr style="line-height:25px">convertView,<a target="_blank" rel="nofollow" href="http://developer.android.com/reference/android/view/ViewGroup.html" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">ViewGroup</a><wbr style="line-height:25px">parent)<span style="line-height:1.3em">Geta<a target="_blank" rel="nofollow" href="http://developer.android.com/reference/android/view/View.html" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">View</a><wbr style="line-height:25px">thatdisplaysinthedropdownpopupthedataatthespecifiedpositioninthedataset.<br style="line-height:25px"></wbr></span><wbr style="line-height:25px">实现了<span style="line-height:25px"><wbr style="line-height:25px">SpinnerAdapter</wbr></span><wbr style="line-height:25px">的类:<br style="line-height:25px"><span style="color:#993300; line-height:25px">BaseAdapter</span><br style="line-height:25px"><span style="color:#0000ff; line-height:25px">ArrayAdapter<br style="line-height:25px">
CursorAdapter</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">ResourceCursorAdapter<br style="line-height:25px">
SimpleCursorAdapter</span><br style="line-height:25px"><span style="color:#0000ff; line-height:25px">SimpleAdapter</span><br style="line-height:25px">
实现了<span style="line-height:25px"><wbr style="line-height:25px">SpinnerAdapter</wbr></span><wbr style="line-height:25px">的接口:<br style="line-height:25px">
无<br style="line-height:25px">
更多可参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/171040579201051049428/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">SpinnerAdapter</a></strong>》</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
</div>
<div style="line-height:25px">
<span style="line-height:25px">三、BaseAdapte</span><br style="line-height:25px">
关于<span style="color:#ff00ff; line-height:25px">BaseAdapte</span>请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/1710405792010415112116352/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">BaseAdapter</a></strong>》</div>
<div style="line-height:25px">
<span style="line-height:25px">四、ArrayAdapter</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#ff00ff; line-height:25px">ArrayAdapter</span><span style="color:#003366; line-height:25px">(数组适配器)的作用就是一个数组和listview之间的桥梁,它可以将数组里边定义的数据一一对应的显示在Listview里边。<br style="line-height:25px">
ListView的每个TextView里边显示的内容就是数组里边的对象调用toString()方法后生成的字符串。</span><br style="line-height:25px">
更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/1710405792010415114817235/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">ArrayAdapter</a></strong>》<br style="line-height:25px"><span style="line-height:25px">五、SimpleAdapter</span><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">SimpleAdapter</span>是ArrayList和ListView的桥梁。这个ArrayList里边的每一项都是一个Map<String,?>类型。<br style="line-height:25px">
ArrayList当中的每一项Map对象都和ListView里边的每一项进行数据绑定一一对应。<br style="line-height:25px">
更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/171040579201043153837703/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">SimpleAdapter</a></strong>》</div>
<div style="line-height:25px">
<span style="line-height:25px">六、CursorAdapter</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#ff00ff; line-height:25px">CursorAdapter</span><span style="color:#003366; line-height:25px">是个虚类,继承于</span><span style="color:#993300; line-height:25px">BaseAdapter</span><span style="color:#003366; line-height:25px">。<br style="line-height:25px">
它有两个虚方法</span><span style="color:#ff6600; line-height:25px">newView</span><span style="color:#003366; line-height:25px">和</span><span style="color:#ff6600; line-height:25px">bindView</span><br style="line-height:25px"><span style="color:#003366; line-height:25px">直接子类只有</span><span style="color:#99cc00; line-height:25px">ResourceCursorAdapter</span><br style="line-height:25px"><span style="color:#003366; line-height:25px">间接子类只有</span><span style="color:#808000; line-height:25px">SimpleCursorAdapter</span><span style="color:#003366; line-height:25px">(它继承于</span><span style="color:#99cc00; line-height:25px">ResourceCursorAdapter</span><span style="color:#003366; line-height:25px">)。</span><br style="line-height:25px">
更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/17104057920105214038479/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">CursorAdapter</a></strong>》<br style="line-height:25px"><span style="line-height:25px">七、ResourceCursorAdapter</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#ff00ff; line-height:25px">ResourceCursorAdapter</span><span style="color:#003366; line-height:25px">是个虚类,它继承于</span><span style="color:#ff6600; line-height:25px">CursorAdapter</span><span style="color:#003366; line-height:25px">。<br style="line-height:25px">
它实现了</span><span style="color:#0000ff; line-height:25px">newView</span><span style="color:#003366; line-height:25px">,但仍然没有实现</span><span style="color:#0000ff; line-height:25px">bindView</span><span style="color:#003366; line-height:25px"><br style="line-height:25px">
直接子类只有</span><span style="color:#993300; line-height:25px">SimpleCursorAdapter</span><span style="color:#003366; line-height:25px">,无间接子类。</span><br style="line-height:25px">
更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/17104057920105242555625/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">ResourceCursorAdapter</a></strong>》<br style="line-height:25px"><span style="line-height:25px">八、SimpleCursorAdapter</span><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">SimpleCursorAdapter</span><span style="color:#003366; line-height:25px">继承于</span><span style="color:#ff6600; line-height:25px">CursorAdapter</span><span style="color:#003366; line-height:25px">。它不是虚类,已经实现了</span><span style="color:#0000ff; line-height:25px">bindView</span><span style="color:#003366; line-height:25px">。</span><br style="line-height:25px">
更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/1710405792010431621954/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">SimpleCursorAdapter</a></strong>》</div>
<div style="line-height:25px">
<span style="line-height:25px">九、WrapperListAdapter</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#ff00ff; line-height:25px">WrapperListAdapter</span><span style="color:#003366; line-height:25px">扩展了</span><span style="color:#ff6600; line-height:25px">ListAdapter</span><span style="color:#003366; line-height:25px">接口<br style="line-height:25px">
实现了</span><span style="color:#993300; line-height:25px">WrapperListAdapter</span><span style="color:#003366; line-height:25px">接口的类只有:</span><span style="color:#ff9900; line-height:25px">HeaderViewListAdapter</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#ff00ff; line-height:25px">WrapperListAdapter</span><span style="color:#003366; line-height:25px">只声明了一个方法:</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#0000ff; line-height:25px">publicabstractListAdaptergetWrappedAdapter()</span><br style="line-height:25px"><span style="line-height:25px">十、HeaderViewListAdapter</span><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">HeaderViewListAdapter</span><span style="color:#003366; line-height:25px">实现了WrapperListAdapter接口,并实现了getWrappedAdapter方法。</span><br style="line-height:25px">
更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/17104057920105271412200/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">HeaderViewListAdapter</a></strong>》</div>
</wbr></wbr></wbr></wbr></wbr></wbr>
相关推荐
万能Adapter数据适配器,
listview适配器,包含 ListViewAdapter和ViewHolder以及简单使用demo代码。该适配器能快速简单绑定数据和操作显示数据。可以对其扩充修改
主要介绍了PHP设计模式:适配器模式Adapter,结合实例形式详细分析了PHP适配器模式Adapter基本概念、功能、原理、用法及操作注意事项,需要的朋友可以参考下
主要介绍了Android ListView和Adapter数据适配器的简单介绍,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
1.2 常用数据适配器(Adapter) 数据展示控件 ListView控件 ListView控件 The ListView control ……> android:id="@+id/lv" android:layout_width="match_parent" android:layout_height="match_parent"> ...
面向Protobuf的Lua数据适配器研究与实现_郑建华.pdf
这个是我写的一个自定义Adapter适配器,用来绑定数据到ListView上。我写的代码非常简单易懂
针对项目中涉及到多个ListView,GradView需要声明多个Adapter的情况,此工具类对其进行的封装抽象,Adapter代码中一行代码即可实现item的控件获取以及数据的设置,极大地提高了开发人员的工作效率。 思路共用部分...
Android实现自定义适配器的ExpandableListView示例,准备一级列表中显示的数据:2个一级列表,分别显示"group1"和"group2",准备第一个一级列表中的二级列表数据:两个二级列表,分别显示"childData1"和"childData2",...
Adapter的作用就是ListView界面与数据之间的桥梁,当列表里的每一项显示到页面时,都会调用Adapter的getView方法返回一个View。想过没有? 在我们的列表有1000000项时会是什么样的?是不是会占用极大的系统资源? ...
MTConnect适配器数据仿真器,可以生成模拟数据。
该插件提供了一个余烬数据适配器,该适配器仅将数据存储在内存中,而页面加载之间没有持久性。 当您想将ember-data用于可能没有服务器支持的URL的临时数据时,此功能很有用。 它是从改编的。 安装 您可以通过运行...
针对项目中涉及到多个ListView,GradView需要声明多个Adapter的情况,此工具类对其进行的封装抽象,Adapter代码中一行代码即可实现item的控件获取以及数据的设置,极大地提高了开发人员的工作效率。 思路共用部分...
数据适配器Excel、Mysql、Sqlserver、Oracle 数据适配器...
目 录 (壹)SQLite数据库简介 (贰)数据库的创建 (叁)数据库的使用 3.1、SQlite的基本操作 ...常用数据适配器(Adapter) BaseAdapter SimpleAdapter ArrayAdapter 实战演练——Android应用市场 (代码
这里面存放的是我博客中BaseAapter适配器的学习代码
博客地址 http://blog.csdn.net/sbsujjbcy/article/details/44887001
USB-CAN接口适配器产品可以利用纬图虚拟仪器公司提供的Ginkgo CAN Adapter Classic工具软件,直接进行CAN总线的配置,发送和接受。用户也可以参考我公司提供的DLL动态链接库编写自己的应用软件,方便开发出CAN系统...
用于 Dropbox 数据存储 API 的 Ember 数据适配器。 将您的应用程序数据存储到其中。 在此处了解有关 Dropbox Datastore 的更多信息: 用法 在使用 Dropbox Datastore API 之前,您需要使用在上注册的 OAuth 重定向 ...
这是一个用于在Finance中构建可伸缩数据适配器的cookiecutter程序包。 快速开始 首先创建一个python虚拟环境: python3 -m venv env source env/bin/activate pip install --upgrade pip 然后安装cookiecutter: ...