Share My Creation [Class]: iMashPager Sliding Panels adopted from AHViewPager

Hi there

This class is an adoption of the AHViewPager from B4A to enable one to add sliding panels to their iOS apps easily. Thanks to Klaus with help in one of the methods. The inspiration for this started when I was converting my b4a app to b4i and this was the major functionality I needed.

In essence, this uses a scrollview with paging enabled with added methods to make it function like AHViewPager. There is no need of a "container" though here.

There is a complete sliding page example here using a PageViewController but I did not want that.

Usage:
Copy the module to your shared code module. In the designer, insert this as a custom view.

The zip file herein contains a working example.
 

Attachments

  • jMashPager.zip
    7 KB · Views: 748
  • page1.png
    page1.png
    9.2 KB · Views: 6,196

fbritop

Active Member
Licensed User
Longtime User
I believe there is an error on your gotoPage sub. It should be like:

B4X:
public Sub GotoPage(Index As Int, bSmooth As Boolean)
    CurrentPage = Index
    Log(sv.Panel.Width)
    sv.ScrollTo((Index) * (sv.Panel.Width/panels.Size), 0, bSmooth)
End Sub
 

cloner7801

Active Member
Licensed User
Longtime User
Hi, thanks for this class
But GotoPage didn't work please help me I change the sub to #3 post but it again didn't work

Update :

I use the class in #2 post its GotoPage sub work but ! when I want to change the page it goes to other page(last page)

I have 3 page and at first I go to page 1
pager.GotoPage(1, True)

But when I want to change the page(scroll) it goes to last page
 
Last edited:

Leni Berry

Active Member
Licensed User
Longtime User
Hi, thanks for this class
But GotoPage didn't work please help me I change the sub to #3 post but it again didn't work

Update :

I use the class in #2 post its GotoPage sub work but ! when I want to change the page it goes to other page(last page)

I have 3 page and at first I go to page 1
pager.GotoPage(1, True)

But when I want to change the page(scroll) it goes to last page

B4X:
public Sub GotoPage(Index As Int, bSmooth As Boolean)
    CurrentPage = Index
    sv.ScrollTo((Index-1) * (sv.Panel.Width/panels.Size), 0, bSmooth)
End Sub
 

Marcus Araujo

Member
Licensed User
Longtime User
Thanks a lot, Mashiane! This is very helpful!!

I have one suggestion, to add the "AddToParent" so we can add the view in runtime. I wrote as below and it worked fine.

B4X:
Public Sub AddToParent(Parent As Panel, Left As Int, Top As Int, Width As Int, Height As Int)
    mBase.Initialize("mBase")
    Parent.AddView(mBase, Left, Top, Width, Height)
    sv.Initialize("sv", mBase.Width, mBase.height)
    mBase.AddView(sv, 0, 0, mBase.Width, mBase.Height)
    sv.PagingEnabled = True
    sv.ShowsHorizontalIndicator = True
End Sub
 

Mike1970

Well-Known Member
Licensed User
Longtime User
I tried this library.. but the content isn't vertically aligned.

rrerr.jpg
(Black border is the imashpager)
 
Top