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

Mashiane

Expert
Licensed User
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

fbritop

Active Member
Licensed 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
 

Mashiane

Expert
Licensed 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
Thanks a lot for this. Will check it out.
 

cloner7801

Active Member
Licensed 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
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
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

Active Member
Licensed User
I tried this library.. but the content isn't vertically aligned.

rrerr.jpg
(Black border is the imashpager)
 

Mashiane

Expert
Licensed User
I havent used this in a long long long while. The bas file included you can customise to meet your needs however there could be something better as the first was in 2016. Sorry I cant be helpful.
 
Top