Android中的适配器
2015-10-31 13:23
337 查看
上网查了很多资料,决定整理些东西,也是对过去一个阶段的总结,里面有很多事网上查找的资料。
首先,Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带。
常用的适配器:
1、SimpleAdapter(简单适配器):一般是与listview、hashmap构成的list一起用的,public SimpleAdapter (Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to)
第一个参数:SimpleAdapter所要运行关联到的视图,即SimpleAdapter所在的Activity
第二个参数:数据源,一般是一个List,他内部存储的则是Map或者继承自Map的对象,比如HashMap
第三个参数:资源文件,加载这个两列所需要的视图资源文件
第四个参数:主要是将Map对象中的名称映射到列名,一一对应
第五个参数:是将第四个参数的值一一对象的显示(一一对应)在接下来的int形的id数组中,这个id数组就是LayOut的xml文件中命名id形成的唯一的int型标识符。
2、BaseAdapter(基础适配器):它是一个接口类,主要用于(Spinner、ListView、GirdView),在Android的官方文档中,
public abstract class
BaseAdapter
extends ObjectimplementsListAdapter SpinnerAdapter
它的直接子类:ArrayAdapter<T>, CursorAdapter, SimpleAdapter
间接子类:
ResourceCursorAdapter, SimpleCursorAdapter
3、PagerAdapter():它是基类,该适配器能填充页面内容到ViewPager中,要实现PagerAdapter的时候,需要重写:
1、instantiateItem(ViewGroup, int)--实例化条目
2、destroyItem(ViewGroup, int, Object)--销毁条目
3、getCount()--获取条目数量
三个方法
4、ArrayAdapter():ArrayAdapter是BaseAdapter的派生类
5、BaseExpandableListAdapter():它的官方文档是这样写着的,
public abstract class
BaseExpandableListAdapter extendsObject
implements
ExpandableListAdapter,HeterogeneousExpandableList
它是一个接口类,
6、SimpleCursorAdapter():在官方文档中,
public interface
SpinnerAdapter extends Adapter
java.lang.Object
android.widget.BaseAdapter
android.widget. SpinnerAdapter
它是这样描述的,这是一个简单的适配器,可以将静态数据映射到XML文件中定义好的视图。
一直在更新。。。。。。
首先,Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带。
常用的适配器:
1、SimpleAdapter(简单适配器):一般是与listview、hashmap构成的list一起用的,public SimpleAdapter (Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to)
第一个参数:SimpleAdapter所要运行关联到的视图,即SimpleAdapter所在的Activity
第二个参数:数据源,一般是一个List,他内部存储的则是Map或者继承自Map的对象,比如HashMap
第三个参数:资源文件,加载这个两列所需要的视图资源文件
第四个参数:主要是将Map对象中的名称映射到列名,一一对应
第五个参数:是将第四个参数的值一一对象的显示(一一对应)在接下来的int形的id数组中,这个id数组就是LayOut的xml文件中命名id形成的唯一的int型标识符。
2、BaseAdapter(基础适配器):它是一个接口类,主要用于(Spinner、ListView、GirdView),在Android的官方文档中,
public abstract class
BaseAdapter
extends ObjectimplementsListAdapter SpinnerAdapter
它的直接子类:ArrayAdapter<T>, CursorAdapter, SimpleAdapter
间接子类:
ResourceCursorAdapter, SimpleCursorAdapter
3、PagerAdapter():它是基类,该适配器能填充页面内容到ViewPager中,要实现PagerAdapter的时候,需要重写:
1、instantiateItem(ViewGroup, int)--实例化条目
2、destroyItem(ViewGroup, int, Object)--销毁条目
3、getCount()--获取条目数量
三个方法
4、ArrayAdapter():ArrayAdapter是BaseAdapter的派生类
5、BaseExpandableListAdapter():它的官方文档是这样写着的,
public abstract class
BaseExpandableListAdapter extendsObject
implements
ExpandableListAdapter,HeterogeneousExpandableList
它是一个接口类,
6、SimpleCursorAdapter():在官方文档中,
public interface
SpinnerAdapter extends Adapter
java.lang.Object
android.widget.BaseAdapter
android.widget. SpinnerAdapter
它是这样描述的,这是一个简单的适配器,可以将静态数据映射到XML文件中定义好的视图。
一直在更新。。。。。。
相关文章推荐
- android-historian
- Android大牛博客地址集合
- Android的webview加载本地html、本apk内html和远程URL
- @*android 引用
- android--(动画2_属性动画)
- 错误记录 1
- Android编程学习之抽象类AbsListView用法实例分析
- Android xml资源文件中@、@android:type、@*、?、@+含义和区别
- 学习Android Studio里的Gradle
- Android 亮度调节
- Android触摸事件分发机制
- Android 性能优化
- Android编程之Button控件用法实例分析
- Android性能优化 浅析
- android--(动画1_动画补间动画和帧动画)
- Android编程中关于单线程模型的理解与分析
- Animation_list动画爆出OOM,你猜怎么着?
- Android5.0-Material Design(done)
- Android编程之高效开发App的10个建议
- android 6.0 Marshmallow