android-PagerAdapter
来源:互联网 发布:mysql免费 编辑:程序博客网 时间:2024/04/29 20:50
PagerAdapter
extends Object类概述
Base class providing the adapter to populate pages inside of a ViewPager
. You will most likely want to use a more specific implementation of this, such asFragmentPagerAdapter
or FragmentStatePagerAdapter
.
When you implement a PagerAdapter, you must override the following methods at minimum:
instantiateItem(ViewGroup, int)
destroyItem(ViewGroup, int, Object)
getCount()
isViewFromObject(View, Object)
PagerAdapter is more general than the adapters used for AdapterViews
. Instead of providing a View recycling mechanism directly ViewPager uses callbacks to indicate the steps taken during an update. A PagerAdapter may implement a form of View recycling if desired or use a more sophisticated method of managing page Views such as Fragment transactions where each page is represented by its own Fragment.
ViewPager associates each page with a key Object instead of working with Views directly. This key is used to track and uniquely identify a given page independent of its position in the adapter. A call to the PagerAdapter method startUpdate(ViewGroup)
indicates that the contents of the ViewPager are about to change. One or more calls to instantiateItem(ViewGroup, int)
and/or destroyItem(ViewGroup, int, Object)
will follow, and the end of an update will be signaled by a call tofinishUpdate(ViewGroup)
. By the time finishUpdate
returns the views associated with the key objects returned by instantiateItem
should be added to the parent ViewGroup passed to these methods and the views associated with the keys passed to destroyItem
should be removed. The method isViewFromObject(View, Object)
identifies whether a page View is associated with a given key object.
A very simple PagerAdapter may choose to use the page Views themselves as key objects, returning them from instantiateItem(ViewGroup, int)
after creation and adding them to the parent ViewGroup. A matching destroyItem(ViewGroup, int, Object)
implementation would remove the View from the parent ViewGroup andisViewFromObject(View, Object)
could be implemented as return view == object;
.
PagerAdapter supports data set changes. Data set changes must occur on the main thread and must end with a call to notifyDataSetChanged()
similar to AdapterView adapters derived from BaseAdapter
. A data set change may involve pages being added, removed, or changing position. The ViewPager will keep the current page active provided the adapter implements the method getItemPosition(Object)
.
概述
destroyItem(ViewGroup, int, Object)
finishUpdate(ViewGroup)
instantiateItem(ViewGroup, int)
instantiateItem(ViewGroup, int)
.saveState()
.setPrimaryItem(ViewGroup, int, Object)
startUpdate(ViewGroup)
常量
public static final int POSITION_NONE
public static final int POSITION_UNCHANGED
- Android PagerAdapter
- android-PagerAdapter
- Android PagerAdapter的用法
- Android适配器之PagerAdapter
- Android PagerAdapter notifyDatasetChanged
- android PagerAdapter用法
- Android ViewPager PagerAdapter
- Android PagerAdapter简介
- android PagerAdapter 快速上车
- android PagerAdapter简单应用
- PagerAdapter
- PagerAdapter
- PagerAdapter
- PagerAdapter
- PagerAdapter
- Android ViewPager 中使用pagerAdapter
- Android关于Pageradapter的总结
- android.support.v4.view.PagerAdapter
- Java String.compareTo()方法
- 猜测:Oracle ash报告中SQL Text 出现"** SQL Text Not Available **"的原因
- Storage
- 【学习拾遗】Jquery(三)--ztree
- Missing variable or function matlab错误
- android-PagerAdapter
- 浅析几种排序
- wsdl2java 生成webService客户端代码,并读取数据
- 提高第38课时,自测
- HTML 常用标签
- Intellij_idea-14官方快捷键中文版
- JS成员函数声明位置优化
- matlab中fspecial中生成高斯模板的解释以及c语言实现
- Android实战简易教程-第五枪(ListView用法研究)