java.lang.Object | ||
↳ | com.neomades.ui.View | |
↳ | com.neomades.ui.ViewPager |
A ViewPager
control allows the user to flip left and right through
pages of data.
Either you supply an implementation of a PagerAdapter (with
setPagerAdapter()
) to generate the
pages that the view shows or you provide views with addView()
for each pages.
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ViewPager()
Creates a new view pager.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
addView(View view, int atIndex)
Inserts a view (as a page) at a specified position.
| ||||||||||
void |
addView(View view)
Adds a new item view (as a page) to the ViewPager.
| ||||||||||
int |
getCurrentPage()
Returns the current selected tab.
| ||||||||||
int |
getViewsCount()
Returns the number of views (or pages) inside this container.
| ||||||||||
boolean |
isEnabled()
Returns a boolean indicating if the ViewPager is enabled or not.
| ||||||||||
void |
notifyDataChanged()
Notifies the pager that data has changed and the pager should update the UI
| ||||||||||
void |
removeAllViews()
Removes all views from this container.
| ||||||||||
void |
removeIndex(int index)
Removes a view from this list at the specified
index . | ||||||||||
void |
removeView(View view)
Removes a view from this list.
| ||||||||||
void |
setCurrentPage(int number)
Changes the current selected page.
| ||||||||||
void |
setEnabled(boolean enabled)
Enables or disables the ViewPager.
| ||||||||||
void |
setOffScreenPageLimit(int pageLimit)
Sets the number of pages that should be buffered to either side of the
current page.
| ||||||||||
void |
setPageChangeListener(PageChangeListener listener)
Sets a page change listener to listen when the user changes the current page.
| ||||||||||
void |
setPagerAdapter(PagerAdapter adapter)
Set a PagerAdapter that will supply views for this pager as needed.
| ||||||||||
void |
setPagerTitleStrip(PagerTitleStrip titleStrip)
Sets a
PagerTitleStrip to this ViewPager. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Creates a new view pager.
Inserts a view (as a page) at a specified position.
view | the view to insert |
---|---|
atIndex | the position index |
CrossThreadException |
---|
Adds a new item view (as a page) to the ViewPager.
view | child to add |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
IllegalStateException | if the view child has already a parent |
Returns the current selected tab.
Returns the number of views (or pages) inside this container.
Returns a boolean indicating if the ViewPager is enabled or not. When the pager is disabled, it cannot be scrolled.
true
if the ViewPager is enabled, false
if
it is disabledNotifies the pager that data has changed and the pager should update the UI
Removes all views from this container.
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Removes a view from this list at the specified index
.
CrossThreadException |
---|
Removes a view from this list.
if the view is not a child of this ListView
, an
IllegalStateException
is thrown.
view | the view to remove |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
IllegalStateException | if the view is not a child of this list |
NullPointerException | if the view is null |
Changes the current selected page. If the index of the page is outside the pager bounds, nothing is done.
number | current tab index |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Enables or disables the ViewPager. When the pager is disabled, it cannot be scrolled.
enabled | the new state of the ViewPager: true for enabled,
false for disabled |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the number of pages that should be buffered to either side of the current page. Pages beyond this limit will be recreated from the adapter when needed.
By default, the limit is set to 1. This is offered as an optimization. If you know in advance the number of pages you will need to support or have lazy-loading mechanisms in place on your pages, tweaking this setting can have benefits in perceived smoothness of paging animations and interaction. If you have a small number of pages (3-4) that you can keep active all at once, less time will be spent in layout for newly created view subtrees as the user pages back and forth. You should keep this limit low, especially if your pages have complex layouts.
pageLimit | the number of pages that should be buffered to either side of the current page |
---|
Sets a page change listener to listen when the user changes the current page.
listener | a listener or null |
---|
Set a PagerAdapter that will supply views for this pager as needed.
adapter | Adapter to use |
---|
Sets a PagerTitleStrip
to this ViewPager. This will enable to display
titles for each pages of the pager. Titles will be displayed above the pager
and will move with their associated page.
titleStrip | the PagerTitleStrip that will contain the titles of the pager pages |
---|