↳ | android.support.v4.view.PagerAdapter |
已知直接子类
,
|
Base class providing the adapter to populate pages inside of a . You will most likely want to use a more specific implementation of this, such as
or
.
When you implement a PagerAdapter, you must override the following methods at minimum:
PagerAdapter is more general than the adapters used for . 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 indicates that the contents of the ViewPager are about to change. One or more calls to
and/or
will follow, and the end of an update will be signaled by a call to
. By the time
returns the views associated with the key objects returned by
should be added to the parent ViewGroup passed to these methods and the views associated with the keys passed to
should be removed. The method
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 after creation and adding them to the parent ViewGroup. A matching
implementation would remove the View from the parent ViewGroup and
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 similar to AdapterView adapters derived from
. 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
.
常量 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | |||||||||||
int |
公有构造函数 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
() |
公有方法 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
(
container, int position,
object)
Remove a page for the given position.
| ||||||||||
void |
(
container, int position,
object)
该 method 从 API 级别 开始已经废弃。 Use
| ||||||||||
void |
(
container)
该 method 从 API 级别 开始已经废弃。 Use
| ||||||||||
void |
(
container)
Called when the a change in the shown pages has been completed.
| ||||||||||
abstract int |
()
Return the number of views available.
| ||||||||||
int |
(
object)
Called when the host view is attempting to determine if an item's position has changed.
| ||||||||||
(int position)
This method may be called by the ViewPager to obtain a title string to describe the specified page.
| |||||||||||
float |
(int position)
Returns the proportional width of a given page as a percentage of the ViewPager's measured width from (0.f-1.f]
| ||||||||||
(
container, int position)
Create the page for the given position.
| |||||||||||
(
container, int position)
该 method 从 API 级别 开始已经废弃。 Use
| |||||||||||
abstract boolean |
(
view,
object)
Determines whether a page View is associated with a specific key object as returned by
.
| ||||||||||
void |
()
This method should be called by the application if the data backing this adapter has changed and associated views should update.
| ||||||||||
void |
(
observer)
Register an observer to receive callbacks related to the adapter's data changing.
| ||||||||||
void |
(
state,
loader)
Restore any instance state associated with this adapter and its pages that was previously saved by
.
| ||||||||||
()
Save any instance state associated with this adapter and its pages that should be restored if the current UI state needs to be reconstructed.
| |||||||||||
void |
(
container, int position,
object)
该 method 从 API 级别 开始已经废弃。 Use
| ||||||||||
void |
(
container, int position,
object)
Called to inform the adapter of which item is currently considered to be the "primary", that is the one show to the user as the current page.
| ||||||||||
void |
(
container)
该 method 从 API 级别 开始已经废弃。 Use
| ||||||||||
void |
(
container)
Called when a change in the shown pages is going to start being made.
| ||||||||||
void |
(
observer)
Unregister an observer from callbacks related to the adapter's data changing.
|
继承方法
| |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
|
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- howto234.com 版权所有 湘ICP备2022005869号-3
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务