B4A Library AHViewPager library - Sliding panels now perfect

This library is a B4A implementation of the ViewPager object provided by the compatibility class from google. With this library it is possible to add sliding panels to your apps.

AHPageContainer - This object is a container for the pages of the AHViewPager. You should add Panels to this object.

AHViewPager - This is the main object which provides the sliding panels.

All the Tabs objects are deprecated now. You can use them but I don't enhance them anymore. For nice looking Tabs please use the DSTabLayout object of the DesignSupport library.
Alternatively you can use the TabStripViewPager.


Installation:
  • From V3.00 on the library requires B4A 6.0 or later.
  • This library depends on the Android Support library so you need to install the Android Support repository in the Extras section with SDK Manager.
  • Copy the AHViewPager.xml and AHViewPager.jar files to your additional libraries folder.
Example project:

For an example project for this library see the Design Support Library.

Your support:
Creating libraries and wrappers for existing library projects is a lot of work. The use of this library is totally free and you even don't need to mention in your app that you use it.
But if you use this library in your projects and you think it is useful to you please consider to make a donation:

Thanks very much for your support.

Version History:

1.00:
- initial version

1.01:
- Added AHViewPagerFixedTabs object for a fixed tab indicator
- Fixed a bug that it was impossible to get the canvas of a panel which was added to the container (It was impossible to display charts on a page)
- Example for AHViewPagerFixedTabs tab indicator

1.02: (Never released)
- Fixes problem with tab height (Line is now always on the bottom)

1.03:
- Fixes problem with Line sometimes not updating correctly on Android 4.0+
- Fix UppercaseTitle property

2.0:
- Complete Rewrite of the Swipey tabs code to fix some bugs with newer android versions.

2.01:
- New property for the AHViewPager object: PagingEnabled - Enables or disables paging for the ViewPager.

2.02:
- New events PageScrolled and PageScrollStateChanged (with SCROLLSTATE constants)
See post 227 for details

2.20:
- Use raiseEventfromUI() in most events
- New SupportTabs object
- New SupportTitles object
- Support for Designer (as a Custom View)
- some minor internal changes and bug fixes

2.21:
- Use raiseEvent() for PageCreated and PageDestroyed event again to prevent double UI refreshes
- Added @RaiseSynchronousEvents annotation to GotoPage() (to make it better compatible with rapid debugger.

3.00:
- Support for Designer Custom Properties.
- Uses maven repository to access support library. (B4A 6.0 or later required)

Attention: V2.20 has an API change which makes the ViewPager incompatible with older versions. The AHPageContainer parameter is removed from the Initialize() method. Initialize2() has the old signature. If you use Initialize() (or add the View to the Designer as a custom view) then you have to set the container object with ViewPager.PageContainer = <YourContainer>

The examples use the old Initialize method, so they are broken. I was too lazy to fix them because I recommend the tab indicator from the Design Support library for a nice looking Material Design app.
 

Attachments

  • screenshot-1336034831196.png
    screenshot-1336034831196.png
    10.1 KB · Views: 8,302
  • screenshot-1336034966953.png
    screenshot-1336034966953.png
    9.9 KB · Views: 7,568
  • AHViewPager2_21.zip
    39.8 KB · Views: 2,542
  • AHViewPager3_00.zip
    74.9 KB · Views: 2,497
Last edited:

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Hi,

I have an APP where I want to disable the gesture support for paging.
I found:

B4X:
AHViewPager.PagingEnabled = False

which does disable the gestures but it also disables the TABS on the top.

Is there a way to turn of the gestures while still using the TABS on the top?

Thanks
 

corwin42

Expert
Licensed User
Longtime User
Hi,

I have an APP where I want to disable the gesture support for paging.
I found:

B4X:
AHViewPager.PagingEnabled = False

which does disable the gestures but it also disables the TABS on the top.

Is there a way to turn of the gestures while still using the TABS on the top?

Thanks

This is not possible.
 

little3399

Active Member
Licensed User
Longtime User
Hi, I place a listview in page0, and loadlayout the xxx.bal , this xxx.bal was created by desinger , and how to and put some message in the listview ,becaseue I adding sth to the listview...,but it can not show anything .... who can help me or give me a solution example ? TKS!



upload_2014-6-18_16-23-11.png
 

Attachments

  • upload_2014-6-18_16-25-12.png
    upload_2014-6-18_16-25-12.png
    155.5 KB · Views: 216
Last edited:

little3399

Active Member
Licensed User
Longtime User
Hi I have try your sample ,but it's page style is not fit for me ,can you provide the page style is fit for me ? ;) TKS!
 

little3399

Active Member
Licensed User
Longtime User
Hi, I found a anchor bug (maybe), like this ....

upload_2014-6-18_22-4-9.png

upload_2014-6-18_22-7-0.png



upload_2014-6-18_22-8-42.png
 

Attachments

  • upload_2014-6-18_22-11-39.png
    upload_2014-6-18_22-11-39.png
    66.7 KB · Views: 179

little3399

Active Member
Licensed User
Longtime User
PageName=Array As String("Page0","Page1","Page2")
Dim PageLayout() As String
PageLayout=Array As String("tasklist","taskedlist","login")

For i = 0 To 2
Dim pan As Panel

pan = CreatePanel(PageName(i))
pan.LoadLayout(PageLayout(i))
container.AddPage(pan,PageName(i))
gPageNumber = i+1
Log(gPageNumber)
Next

pager.Initialize(container, "Pager")
 

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I need to do an action on change of the page.
Sub Pager_PageChanged (Position As Int) is called after the change: The new page is already active.

My use:
I put information from a SQL database on a page. I want to write this information back once the user changes to the next page.

Is there something like "Sub Pager_PageLeave" so I can use the fields of the leaving page to write to my database?

Does anyone has a solution?

Best regards,
André
 

jrostek

New Member
Licensed User
Longtime User
Hi,
nice lib.

But 2 questions.

1. Is there a way to implement a picture in each Tab?
2. How can i define the tabheight in correct way?

Thanks
 

corwin42

Expert
Licensed User
Longtime User
Hi,
nice lib.

But 2 questions.

1. Is there a way to implement a picture in each Tab?
2. How can i define the tabheight in correct way?

Thanks

1. No, currently not
2. The tab height is a bit tricky because internally the view for the text is exactly as high as the tab text. So the underline is exactly under it. You can change the text size and the tab padding to size the tab object properly.
 

corwin42

Expert
Licensed User
Longtime User
Hi,

I need to do an action on change of the page.
Sub Pager_PageChanged (Position As Int) is called after the change: The new page is already active.

My use:
I put information from a SQL database on a page. I want to write this information back once the user changes to the next page.

Is there something like "Sub Pager_PageLeave" so I can use the fields of the leaving page to write to my database?

Does anyone has a solution?

You can use the PageScrollStateChanged event to detect when the user starts dragging a page.
 

luke2012

Well-Known Member
Licensed User
Longtime User
This library is a B4A implementation of the ViewPager object provided by the compatibility class from google. With this library it is possible to add sliding panels to your apps with a very nice tab selector and page indicator like in some google apps (Market etc)

There are four objects in this library:

AHPageContainer - This object is a container for the pages of the AHViewPager. You should add Panels to this object.

AHViewPager - This is the main object which provides the sliding panels.

AHViewPagerTabs - This (optional) object provides a nice tab selector and indicator for the sliding panels. This object is based on the ViewPagerTabs implementation from Andreas Stütz and you can find it here.

AHViewPagerFixedTabs - This (optional) object provides a nice tab selector with fixed tabs. This object is based on the ViewPagerExtensions library from Andreas Stütz See here
For a detailed usage explanation see the example project.

Installation:
You need at least B4A 1.8.
Copy the jar file and the xml file to your custom libs folder.
Copy the android-support-v4.jar from the Android SDK to your custom libs folder (see below)

Attention: This library uses the android-support-v4.jar library. You have to install it with the Android SDK Manager. Please add the Extras/Android Support package. Then you will find the jar under <SDK root folder>\extras\android\support\v4. Please copy the android-support-v4.jar file to your custom libs folder!

Version History:

1.00:
- initial version

1.01:
- Added AHViewPagerFixedTabs object for a fixed tab indicator
- Fixed a bug that it was impossible to get the canvas of a panel which was added to the container (It was impossible to display charts on a page)
- Example for AHViewPagerFixedTabs tab indicator

1.02: (Never released)
- Fixes problem with tab height (Line is now always on the bottom)

1.03:
- Fixes problem with Line sometimes not updating correctly on Android 4.0+
- Fix UppercaseTitle property

2.0:
- Complete Rewrite of the Swipey tabs code to fix some bugs with newer android versions.

2.01:
- New property for the AHViewPager object: PagingEnabled - Enables or disables paging for the ViewPager.

2.02:
- New events PageScrolled and PageScrollStateChanged (with SCROLLSTATE constants)
See post 227 for details

It's possible to reduce the spacing between the tabs ?
 
Top