Android Programming Press on the image to return to the main documentation page.

AHViewPager

Written by Markus Stipp

This library provides objects to implement a CustomViewPager.

List of types:

AHPageContainer
AHViewPager
AHViewPagerFixedTabs
AHViewPagerSupportTabs
AHViewPagerSupportTitles
AHViewPagerTabs

AHPageContainer

AHPagerLayout holds the layout of the pages
This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

None

Members:


  AddPage (View As android.view.View, Title As String)

  AddPageAt (View As android.view.View, Title As String, Position As Int)

  Count As Int [read only]

  DeletePage (Position As Int)

  GetPageObject (Position As Int) As Object

  getPageWidth (arg0 As Int) As Float

  GetTitle (Position As Int) As String

  Initialize

  Initialize2 (Pages As List, Titles As List)

  IsInitialized As Boolean [read only]

  notifyDataSetChanged

  Pages As List [read only]

  registerDataSetObserver (arg0 As android.database.DataSetObserver)

  SetContent (Pages As List, Titles As List)

  SetTitle (Title As String, Position As Int)

  Titles As List [read only]

  unregisterDataSetObserver (arg0 As android.database.DataSetObserver)

Members description:

AddPage (View As android.view.View, Title As String)
Add a new page to the pager layout. Normally you will provide a Panel here.
View - The view to be added as a new page
Title - The title of the new page
AddPageAt (View As android.view.View, Title As String, Position As Int)
Add a new page to the pager layout at the specified position. Normally you will provide a Panel here.
View - The view to be added as a new page
Title - The title of the new page
Position - Position where the new page will be added
Count As Int [read only]
Gets the number of pages in the layout.
DeletePage (Position As Int)
Deletes the specified page.
Position - Page to be deleted
GetPageObject (Position As Int) As Object
Returns the View added as a page. Normally this is a Panel object.
Position - Index of the object
getPageWidth (arg0 As Int) As Float
GetTitle (Position As Int) As String
Gets the title of the page.

Position - Position of the title to get.
Initialize
Initializes the object
Initialize2 (Pages As List, Titles As List)
IsInitialized As Boolean [read only]
notifyDataSetChanged
Pages As List [read only]
The List or Array of the pages.
registerDataSetObserver (arg0 As android.database.DataSetObserver)
SetContent (Pages As List, Titles As List)
Sets the pages and titles for the container

Pages - A List or Array of Panel objects
Titles - A List or Array of page titles
SetTitle (Title As String, Position As Int)
Sets the title of the page.

Title - The new title text.
Position - Position of the title to change.
Titles As List [read only]
The List or Array of the titles.
unregisterDataSetObserver (arg0 As android.database.DataSetObserver)

AHViewPager


This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

PageChanged (Position As Int)
PageScrollStateChanged (State as Int)
PageScrolled (Position As Int, PositionOffset as Float, PositionOffsetPixels as Int)
PageCreated (Position As Int, Page as Object)
PageDestroyed (Position As Int, Page as Object)

Members:


  Background As android.graphics.drawable.Drawable

  BringToFront

  Color As Int [write only]

  CurrentPage As Int

  DesignerCreateView (base As PanelWrapper, label As LabelWrapper, props As Map)

  Enabled As Boolean

  GotoPage (Page As Int, Smooth As Boolean)

  Height As Int

  Initialize (EventName As String)

  Initialize2 (Container As AHPageContainer, EventName As String)

  Invalidate

  Invalidate2 (Rect As android.graphics.Rect)

  Invalidate3 (Left As Int, Top As Int, Right As Int, Bottom As Int)

  IsInitialized As Boolean

  Left As Int

  OffscreenPageLimit As Int

  PageContainer As AHPageContainer [write only]

  PageMargin As Int

  PagingEnabled As Boolean

  Parent As Object [read only]

  RemoveView

  RequestFocus As Boolean

  SCROLLSTATE_DRAGGING As Int

  SCROLLSTATE_IDLE As Int

  SCROLLSTATE_SETTLING As Int

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap)

  SetColorAnimated (Duration As Int, FromColor As Int, ToColor As Int)

  SetLayout (Left As Int, Top As Int, Width As Int, Height As Int)

  SetLayoutAnimated (Duration As Int, Left As Int, Top As Int, Width As Int, Height As Int)

  SetVisibleAnimated (Duration As Int, Visible As Boolean)

  Tag As Object

  Top As Int

  Visible As Boolean

  Width As Int

Members description:

Background As android.graphics.drawable.Drawable
BringToFront
Color As Int [write only]
CurrentPage As Int
Get or Set the current page
DesignerCreateView (base As PanelWrapper, label As LabelWrapper, props As Map)
This method is only for the B4A Designer. Don't call it directly
Enabled As Boolean
GotoPage (Page As Int, Smooth As Boolean)
Jump or Scroll to the new page Page - The new page to display Smooth -
True to smoothly scroll to the new item, false to transition immediately
Height As Int
Gets or sets the view's height
Initialize (EventName As String)
Initializes the object.

pages EventName - Sets the sub that will handle the event.
Initialize2 (Container As AHPageContainer, EventName As String)
Initializes the object.

Layout - A fully initialized AHPagerLayout object with the content of the
pages EventName - Sets the sub that will handle the event.
Invalidate
Invalidate2 (Rect As android.graphics.Rect)
Invalidate a rectangualar part of the object
Invalidate3 (Left As Int, Top As Int, Right As Int, Bottom As Int)
Invalidate part of the object
IsInitialized As Boolean
Left As Int
Gets or sets the view's left position
OffscreenPageLimit As Int
Set the number of pages that should be retained to either side of the
current page in the view hierarchy in an idle state. Pages beyond this
limit will be recreated from the adapter when needed.

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. This setting defaults to 1.
PageContainer As AHPageContainer [write only]
PageMargin As Int
Set the margin between pages.
PagingEnabled As Boolean
Enables or disables the paging of the ViewPager.
Parent As Object [read only]
RemoveView
RequestFocus As Boolean
SCROLLSTATE_DRAGGING As Int
SCROLLSTATE_IDLE As Int
SCROLLSTATE_SETTLING As Int
SendToBack
SetBackgroundImage (arg0 As android.graphics.Bitmap)
SetColorAnimated (Duration As Int, FromColor As Int, ToColor As Int)
Animate the color to a new value
SetLayout (Left As Int, Top As Int, Width As Int, Height As Int)
Changes the View position and size.
SetLayoutAnimated (Duration As Int, Left As Int, Top As Int, Width As Int, Height As Int)
Similar to SetLayout. Animates the change. Note that the animation will only be applied when running on Android 3+ devices.

Duration - duration of the layout change
SetVisibleAnimated (Duration As Int, Visible As Boolean)
Fade the view in or out
Tag As Object
Top As Int
Gets or sets the view's top position
Visible As Boolean
Width As Int
Gets or sets the view's width

AHViewPagerFixedTabs


This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

None

Members:


  Background As android.graphics.drawable.Drawable

  BringToFront

  Color As Int [write only]

  Enabled As Boolean

  Height As Int

  Initialize (Pager As AHViewPager)

  Invalidate

  Invalidate2 (arg0 As android.graphics.Rect)

  Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  IsInitialized As Boolean

  Left As Int

  LineColor As Int

  LineColorSelected As Int

  LineHeight As Int

  LineHeightSelected As Int

  NotifyDataChange

  Parent As Object [read only]

  RefreshTitles

  RemoveView

  RequestFocus As Boolean

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap)

  SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)

  SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)

  SetVisibleAnimated (arg0 As Int, arg1 As Boolean)

  Tag As Object

  TextColor As Int

  TextSize As Float

  Top As Int

  UpperCaseTitle As Boolean [write only]

  Visible As Boolean

  Width As Int

Members description:

Background As android.graphics.drawable.Drawable
BringToFront
Color As Int [write only]
Enabled As Boolean
Height As Int
Initialize (Pager As AHViewPager)
Initializes the object.

Pager - A fully initialized AHViewPager object.
Invalidate
Invalidate2 (arg0 As android.graphics.Rect)
Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
IsInitialized As Boolean
Left As Int
LineColor As Int
LineColorSelected As Int
LineHeight As Int
LineHeightSelected As Int
NotifyDataChange
Rebuilds the complete tabs data structure. You MUST call this after you add or remove a page from the AHViewPager.
Parent As Object [read only]
RefreshTitles
Refresh the titles of the tabs. Use this after changing a title in AHPageContainer.
RemoveView
RequestFocus As Boolean
SendToBack
SetBackgroundImage (arg0 As android.graphics.Bitmap)
SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
Tag As Object
TextColor As Int
TextSize As Float
Gets the current position in the tabs.
Top As Int
UpperCaseTitle As Boolean [write only]
Visible As Boolean
Width As Int

AHViewPagerSupportTabs


This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

None

Members:


  Background As android.graphics.drawable.Drawable

  BringToFront

  Color As Int [write only]

  DrawFullUnderline As Boolean

  Enabled As Boolean

  Height As Int

  Initialize (Pager As AHViewPager, Top As Boolean, Height As Int)

  Invalidate

  Invalidate2 (arg0 As android.graphics.Rect)

  Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  IsInitialized As Boolean

  Left As Int

  Parent As Object [read only]

  RemoveView

  RequestFocus As Boolean

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap)

  SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)

  SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)

  SetVisibleAnimated (arg0 As Int, arg1 As Boolean)

  TabIndicatorColor As Int

  Tag As Object

  TextColor As Int [write only]

  TextSize As Float [write only]

  Top As Int

  Visible As Boolean

  Width As Int

Members description:

Background As android.graphics.drawable.Drawable
BringToFront
Color As Int [write only]
DrawFullUnderline As Boolean
Sets or gets the flag if the text is undelined completely
Enabled As Boolean
Height As Int
Initialize (Pager As AHViewPager, Top As Boolean, Height As Int)
Initializes the object.

Pager - A fully initialized AHViewPager object.
Top - Flag if the indicator should be displayed on top or bottom of the ViewPager
Height - The height of the indicator view.
Invalidate
Invalidate2 (arg0 As android.graphics.Rect)
Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
IsInitialized As Boolean
Left As Int
Parent As Object [read only]
RemoveView
RequestFocus As Boolean
SendToBack
SetBackgroundImage (arg0 As android.graphics.Bitmap)
SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
TabIndicatorColor As Int
Sets or gets the tab indicator color
Tag As Object
TextColor As Int [write only]
Sets the text color
TextSize As Float [write only]
Sets the text size
Top As Int
Visible As Boolean
Width As Int

AHViewPagerSupportTitles


This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

None

Members:


  Background As android.graphics.drawable.Drawable

  BringToFront

  Color As Int [write only]

  Enabled As Boolean

  Height As Int

  Initialize (Pager As AHViewPager, Top As Boolean, Height As Int)

  Invalidate

  Invalidate2 (arg0 As android.graphics.Rect)

  Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  IsInitialized As Boolean

  Left As Int

  Parent As Object [read only]

  RemoveView

  RequestFocus As Boolean

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap)

  SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)

  SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)

  SetVisibleAnimated (arg0 As Int, arg1 As Boolean)

  Tag As Object

  TextColor As Int [write only]

  TextSize As Float [write only]

  Top As Int

  Visible As Boolean

  Width As Int

Members description:

Background As android.graphics.drawable.Drawable
BringToFront
Color As Int [write only]
Enabled As Boolean
Height As Int
Initialize (Pager As AHViewPager, Top As Boolean, Height As Int)
Initializes the object.

Pager - A fully initialized AHViewPager object.
Top - Flag if the indicator should be displayed on top or bottom of the ViewPager
Height - The height of the indicator view.
Invalidate
Invalidate2 (arg0 As android.graphics.Rect)
Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
IsInitialized As Boolean
Left As Int
Parent As Object [read only]
RemoveView
RequestFocus As Boolean
SendToBack
SetBackgroundImage (arg0 As android.graphics.Bitmap)
SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
Tag As Object
TextColor As Int [write only]
Sets the text color
TextSize As Float [write only]
Sets the text size
Top As Int
Visible As Boolean
Width As Int

AHViewPagerTabs


This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

None

Members:


  Background As android.graphics.drawable.Drawable

  BackgroundColorPressed As Int

  BringToFront

  Color As Int [write only]

  Enabled As Boolean

  Height As Int

  Initialize (Pager As AHViewPager)

  Invalidate

  Invalidate2 (arg0 As android.graphics.Rect)

  Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  IsInitialized As Boolean

  Left As Int

  LineColorCenter As Int

  LineHeight As Int

  NotifyDataChange

  OutsideOffset As Int

  Parent As Object [read only]

  Position As Int [read only]

  RefreshTitles

  RemoveView

  RequestFocus As Boolean

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap)

  SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)

  SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)

  SetTabPadding (Left As Int, Top As Int, Right As Int, Bottom As Int)

  SetVisibleAnimated (arg0 As Int, arg1 As Boolean)

  TabPaddingBottom As Int

  TabPaddingLeft As Int

  TabPaddingRight As Int

  TabPaddingTop As Int

  Tag As Object

  TextColor As Int

  TextColorCenter As Int

  TextSize As Float

  Top As Int

  UpperCaseTitle As Boolean [write only]

  Visible As Boolean

  Width As Int

Members description:

Background As android.graphics.drawable.Drawable
BackgroundColorPressed As Int
BringToFront
Color As Int [write only]
Enabled As Boolean
Height As Int
Initialize (Pager As AHViewPager)
Initializes the object.

Pager - A fully initialized AHViewPager object.
Invalidate
Invalidate2 (arg0 As android.graphics.Rect)
Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
IsInitialized As Boolean
Left As Int
LineColorCenter As Int
LineHeight As Int
NotifyDataChange
Rebuilds the complete tabs data structure. You MUST call this after you add or remove a page from the AHViewPager.
OutsideOffset As Int
Parent As Object [read only]
Position As Int [read only]
Gets the current position in the tabs.
RefreshTitles
Refresh the titles of the tabs. Use this after changing a title in AHPageContainer.
RemoveView
RequestFocus As Boolean
SendToBack
SetBackgroundImage (arg0 As android.graphics.Bitmap)
SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
SetTabPadding (Left As Int, Top As Int, Right As Int, Bottom As Int)
SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
TabPaddingBottom As Int
TabPaddingLeft As Int
TabPaddingRight As Int
TabPaddingTop As Int
Tag As Object
TextColor As Int
TextColorCenter As Int
TextSize As Float
Top As Int
UpperCaseTitle As Boolean [write only]
Visible As Boolean
Width As Int

Top