1.简介

Adapter的作用是为GridView,ListView等界面控件与数据之间搭建桥梁,每当列表里的每一项显示到页面时,都会调用到Adapter的getView方法

返回一个View.在Android API中内置了几个实现ListAdapter的Adapter,它们分别为BaseAdapter,SimpleAdapter(以Map形式存储静态数据),

SimpleCursorAdapter。Adapter,数据和UI三者关系如下:

Android开发--Adapter的应用

2.BaseAdapter

自定义BaseAdapter类需要重写的方法

返回值                         方法名                                                                                           功能说明

int                          getCount()                                                                                获取当前Adapter的Item数目

Object                     getItem(int position)                                                                  获取相应position的Item

long                       getItemId(int position)                                                                获取相应position的Item在List中的row id

View                       getView(int position,View convertView,ViewGroup parent)               获取指定position所要显示的data的View

相关文章:

  • 2022-02-19
  • 2021-07-15
  • 2021-08-16
  • 2021-07-30
  • 2021-11-04
  • 2021-07-16
  • 2021-08-07
  • 2021-06-06
猜你喜欢
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2021-11-28
  • 2021-07-01
相关资源
相似解决方案