Android Question Wobble Menu with B4XPages

pliroforikos

Active Member
Licensed User
After reading the threads about wonderful WobbleMenu i'm trying to make it work with B4XPages.
I am totally lost. Nothing seems to work correct. I have trouble showing the correct tab when i'm clicking it and trouble with back button of every B4XPage.
Bellow i have a small demonstration project with mainPage and 2 additional B4XPages if someone can advice/help me.

In every page i have almost the same code:

MainPage:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    pg1.Initialize
    B4XPages.AddPage("pg1", pg1)
    pg2.Initialize
    B4XPages.AddPage("pg2", pg2)
    WobbleMenu1.SetTabTextIcon(1,"Main Page", Chr(0xE3D0), Typeface.MATERIALICONS)
    WobbleMenu1.SetTabTextIcon(2,"Page 1", Chr(0xE3D1), Typeface.MATERIALICONS)
    WobbleMenu1.SetTabTextIcon(3,"Page 2", Chr(0xE3D2), Typeface.MATERIALICONS)
    WobbleMenu1.SetCurrentTab2(1, False)
    SetWobbleMenuPosition(WobbleMenu1, 1)
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.


Sub SetWobbleMenuPosition(wm As WobbleMenu, thisTab As Int)
    If wm.GetCurrentTab <> thisTab Then
        wm.SetCurrentTab2(thisTab, False)
    End If
End Sub

Sub WobbleMenu1_Tab1Click
    B4XPages.ShowPage("MainPage")
End Sub

Sub WobbleMenu1_Tab2Click
    B4XPages.ShowPage("pg1")
End Sub

Sub WobbleMenu1_Tab3Click
    B4XPages.ShowPage("pg2")
End Sub

B4xPage1:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("pg1")
    WobbleMenu1.SetTabTextIcon(1,"Main Page", Chr(0xE3D0), Typeface.MATERIALICONS)
    WobbleMenu1.SetTabTextIcon(2,"Page 1", Chr(0xE3D1), Typeface.MATERIALICONS)
    WobbleMenu1.SetTabTextIcon(3,"Page 2", Chr(0xE3D2), Typeface.MATERIALICONS)
    WobbleMenu1.SetCurrentTab2(2, False)
    SetWobbleMenuPosition(WobbleMenu1, 2)
End Sub

Sub SetWobbleMenuPosition(wm As WobbleMenu, thisTab As Int)
    If wm.GetCurrentTab <> thisTab Then
        wm.SetCurrentTab2(thisTab, False)
    End If
End Sub

Sub WobbleMenu1_Tab1Click
    B4XPages.ShowPage("MainPage")
End Sub

Sub WobbleMenu1_Tab2Click
    B4XPages.ShowPage("pg1")
End Sub

Sub WobbleMenu1_Tab3Click
    B4XPages.ShowPage("pg2")
End Sub
 

Attachments

  • Project.zip
    18.6 KB · Views: 68

oparra

Well-Known Member
Licensed User
this can guide you.

Note:
Use "XUI" to create the fonts

Note that tab animations will be lost between pages.

it is better to use panels where you load each design of the tabs

Sample:
PanelPage1.LoadLayout("page1")
PanelPage2.LoadLayout("page2")
PanelPage3.LoadLayout("page3")
 

Attachments

  • B4XPageWobbleMenu.zip
    13.8 KB · Views: 82
  • 1.gif
    1.gif
    150.7 KB · Views: 91
Last edited:
Upvote 0

pliroforikos

Active Member
Licensed User
A second approach without calling AddPageAndCreate in MainPage is to put in click events:

B4X:
Sub WobbleMenu1_Tab1Click
    B4XPages.ShowPage("MainPage")
End Sub

Sub WobbleMenu1_Tab2Click
    if B4XPages.pg1.WobbleMenu1.IsInitialized then
        pg1.WobbleMenu1.SetCurrentTab(2)
    End IF
    B4XPages.ShowPage("pg1")
End Sub

Sub WobbleMenu1_Tab3Click
    if B4XPages.pg2.WobbleMenu1.IsInitialized then
        pg2.WobbleMenu1.SetCurrentTab(3)
    End IF
    B4XPages.ShowPage("pg2")
End Sub

And thats it because many things happens in create and appear in my project and things getting confused.
 
Upvote 0
Top