温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android中的Adapter体系有什么用

发布时间:2022-04-12 14:27:47 来源:亿速云 阅读:149 作者:iii 栏目:编程语言

本篇内容主要讲解“Android中的Adapter体系有什么用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Android中的Adapter体系有什么用”吧!

我们先来看看Adapter的体系:

public interface Adapter----0层(表示继承体系中的层次)

public interface ExpandableListAdapter---(无所谓层次因为没有其他接口继承实现它)

这是adapter的始祖,其他个性化的adapter均实现它并加入自己的接口。

public interface ListAdapter----1层

public interface SpinnerAdapter----1层

public interface WrapperListAdapter----2层(实现ListAdapter)

以上接口层面上的体系已经完了。可以看出来作为widgetview的桥梁adapter其实只分为2种:ListAdapter和SpinnerAdapter以及ExpandableListAdapter。也就是说所有widget也就是基于list和spinne与ExpandableList三种view形式的。

由于在实际使用时,我们需要将数据加入到Adapter,而以接口形式呈现的adapter无法保存数据,于是Adapter就转型为类的模式。

public abstract class BaseAdapter----2层(实现了ListAdapter和SpinnerAdapter)

以抽象类的形式出现构造了类型态下的顶层抽象,包容了List和Spinner

public class ArrayAdapter----3层

public class SimpleAdapter---3层

public class CursorAdapter----3层(CursorAdapter其后还有子类这里先不探讨)

基本体系有了之后,让我们看看顶层Adapter里有哪些方法(只列举常用的):

abstract Object getItem(int position)  abstract int getCount()  abstract long getItemId(int position)  abstract int getItemViewType(int position)  abstract View getView(int position,View convertVeiw,ViewGroup parent)

到此,相信大家对“Android中的Adapter体系有什么用”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI