B4A Library [B4X] [XUI] AS TabMenuAdvanced

fbritop

Active Member
Licensed User
Longtime User
This looks great, is there, or how can a tab width be setted in order to make the tab only with a single line, but the width achieved for every tab, calculating the width on our side with b4xRect?

Thanks!
 

fbritop

Active Member
Licensed User
Longtime User
Sorry thats not possible. That's not what the view is made for. If you want a view that can do that, then have a look at the AS_SegmentedTab
Thanks... This could be an update. A method to remove all views. I do it manually right now

B4X:
                If xFlowTab.GetTabs.Size>0 Then
                    For i=xFlowTab.GetTabs.Size-1 To 0 Step -1
                        xFlowTab.RemoveTabAt(i)
                    Next
                End If
                xFlowTab.Refresh
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.13
    • BugFix - the badge was not round when the width was smaller than the height
    • Add BadgeValue - Sets the badge value without having to call refresh
    • set Index no longer needs a "refresh" to be changed
 
Last edited:

Sergio Haurat

Active Member
Licensed User
Longtime User
Hello @Alexander Stolte, I'm trying to do something that I'm not sure if the [B4X] [XUI] AS TabMenuAdvanced library is designed for. Basically, I want to add some icons; if I select the first one, it clears the current configuration and displays others. Here's the code that builds the menu.
Sub makeMenu:
Private Sub makeMenu(strView As String)
    If btnTabMenu.GetTabs.Size > 0 Then
        btnTabMenu.Clear
    End If
    Select Case strView
        Case "main"
            btnTabMenu.AddTab("", xui.LoadBitmap(File.DirAssets, "icon_user_db.png"), xui.LoadBitmap(File.DirAssets,"icon_user_db.png"))
            btnTabMenu.AddTab("", xui.LoadBitmap(File.DirAssets, "icon_chart.png"), xui.LoadBitmap(File.DirAssets, "icon_chart.png"))
            btnTabMenu.AddTab("", xui.LoadBitmap(File.DirAssets, "icon_padlock.png"), xui.LoadBitmap(File.DirAssets, "icon_padlock.png"))
            btnTabMenu.AddTab("", xui.LoadBitmap(File.DirAssets, "icon_social.png"), xui.LoadBitmap(File.DirAssets,"icon_social.png"))
            btnTabMenu.GetTab(0).xTab.Tag = "userDB"
            btnTabMenu.GetTab(1).xTab.Tag = "chart"
            btnTabMenu.GetTab(2).xTab.Tag = "padLock"
            btnTabMenu.GetTab(3).xTab.Tag = "social"
            If Not(Main.blnIsDBConnected) Then
                btnTabMenu.GetTab(0).xTab.Enabled = False
                btnTabMenu.GetTab(1).xTab.Enabled = False
                btnTabMenu.GetTab(2).xTab.Enabled = False
            End If
            btnTabMenu.AddTab("", xui.LoadBitmap(File.DirAssets, "icon_exit.png"), xui.LoadBitmap(File.DirAssets,"icon_exit.png"))
            btnTabMenu.GetTab(4).xTab.Tag = "exit"
        Case "userDB"
            btnTabMenu.AddTab("", xui.LoadBitmap(File.DirAssets, "icon_find.png"), xui.LoadBitmap(File.DirAssets,"icon_find.png"))
            btnTabMenu.AddTab("", xui.LoadBitmap(File.DirAssets, "icon_edit.png"), xui.LoadBitmap(File.DirAssets, "icon_edit.png"))
            btnTabMenu.AddTab("", xui.LoadBitmap(File.DirAssets, "icon_previus.png"), xui.LoadBitmap(File.DirAssets,"icon_previus.png"))
            btnTabMenu.GetTab(0).xTab.Tag = "findTeam"
            btnTabMenu.GetTab(1).xTab.Tag = "editUser"
            btnTabMenu.GetTab(2).xTab.Tag = "back"
    End Select
    btnTabMenu.Refresh
End Sub
Sub btnTabMenu_TabClick:
Private Sub btnTabMenu_TabClick (Index As Int)
    Select Case btnTabMenu.GetTab(Index).xTab.Tag
        Case "userDB"
            makeMenu("userDB")
        Case "back"
            makeMenu("main")
        Case "exit"
            #if B4a
            Msgbox2Async(Main.loc.Localize("exit_app"), Main.loc.Localize("app_name"), Main.loc.Localize("yes"), "", Main.loc.Localize("cancel"), Null, False)
            Wait For MsgBox_Result (Result As Int)
            If Result = DialogResponse.POSITIVE Then
                Root.RemoveAllViews
                B4XPages.ClosePage(Me)
                ExitApplication
            End If
            #else if B4i
            Msgbox2("Msg", Main.loc.Localize("exit_app"), Main.loc.Localize("app_name"), Array (Main.loc.Localize("yes"), Main.loc.Localize("cancel")))
            Wait For Msg_Click (ButtonText As String)
            If ButtonText = Main.loc.Localize("yes") Then
                Root.RemoveAllViews
                B4XPages.ClosePage(Me)
            End If
      #End If
    End Select
End Sub

On the first run, it doesn't generate any issues. However, when I select the icon with the Tag userDB, it shows the following error.


Thank you for your response and for your great work.
 

Sergio Haurat

Active Member
Licensed User
Longtime User
Can you please show me this in an example project? Thank you
I'll prepare it in minutes and attach it.

A possible bug in version 1.13 that doesn't require a refresh is that when btnTabMenu.Index = -1 is used to prevent it from being selected by default, it now generates the following error.

 

Alexander Stolte

Expert
Licensed User
Longtime User
A possible bug in version 1.13 that doesn't require a refresh is that when btnTabMenu.Index = -1 is used to prevent it from being selected by default, it now generates the following error.
This is not a bug, because there is a property for this:
Just uncheck the "First Tab Selected" property in the designer
 

Sergio Haurat

Active Member
Licensed User
Longtime User
This is not a bug, because there is a property for this:
Just uncheck the "First Tab Selected" property in the designer
View attachment 149738
It works perfectly. I hadn't noticed the property in the designer. Now I'm removing .Index - 1 from the entire code.

I'm attaching the example project you requested in this post
 

Attachments

  • AS TabMenuAdvanced.zip
    134.9 KB · Views: 58

fbritop

Active Member
Licensed User
Longtime User
Hi,
How can we "Ignore" TabClick?

I have an App that takes a little bit to load the results, but if the user switchs tabs, the event gets trigger. I have overcome this by having a "Working" Flag indicator, it acomplishes the job, but the tab indicator switches anyway, causing a little confusion. Is there any "IgnoreEvents" option?

THanks
FBP
 

fbritop

Active Member
Licensed User
Longtime User
Took the freedom to modify it, maybe could be of help for a new version

Line 114
B4X:
Private m_IgnoreEvents as Boolean=False

Line 404
B4X:
Public Sub setIgnoreEvents(Ignore as Boolean)
    m_IgnoreEvents=Ignore
End Sub

Line 574
B4X:
If isUserTap and Not(m_IgnoreEvents) Then


Line 644
B4X:
If isUserTap and Not(m_IgnoreEvents) Then TabClickEvent(m_Index)
 

Alexander Stolte

Expert
Licensed User
Longtime User
Even with an ignore event, the user can switch tabs, only without an event, which also causes confusion.

The library has a much better function than an ignore event.
Disable the tabs and activate it again when you have finished loading.
B4X:
    For Each TabIntern As ASTabMenuAdvanced_TabIntern In AS_TabMenuAdvanced1.GetTabs
        TabIntern.xTab.Enabled = False
    Next
    AS_TabMenuAdvanced1.Refresh

Please always open a new thread if you have any questions, thank you very much, have a good start to the week.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…