Android Question Showing a custom B4XDialog in B4XPages when pressing button

iglrs1

Member
Licensed User
Longtime User
Hi,
I would like to show a custom dialog using B4XDialog when I press on a button (filter button) in B4XPages Toolbar. Someone can help me with an example?
Thanks
 

Attachments

  • img.jpg
    img.jpg
    76.6 KB · Views: 125
Last edited:

William Lancee

Well-Known Member
Licensed User
Longtime User
With a bit of study, you'll see that CustomListView is an easy way to implement a wide variety of views.

I used this example from @Erel: https://www.b4x.com/android/forum/threads/b4x-b4xpages-menu-badges.133301/
In designer...
1. Add panel1 where you want your dialogue, set visible = false
2. Add a generic CustomListView (XUI Views Library) to THAT panel1, use the fill anchors, but leave a little space on the sides for the border.
3 Use code below to fill the list and respond to click event.

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    B4XPages.SetTitle(Me, "Menu Icons")
    Root.LoadLayout("MainPage")

    CartBitmap = xui.LoadBitmap(File.DirAssets, "cart.png")
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 32dip, 32dip)
    IconCanvas.Initialize(p)
    UpdateMenuItems
  
    'Add the following
    addCustomItem("Item")
    addCustomItem("Another Item")
    addCustomItem("A Third Item")
    addCustomItem("A Final Item")
    CustomListView1.PressedColor = xui.Color_Transparent
End Sub

Private Sub B4XPage_MenuClick (Tag As String)
    If Tag = "cart" Then Panel1.Visible = True
End Sub

Private Sub addCustomItem(text As String)
    Dim w As Float = CustomListView1.GetBase.Width
  
    Dim pnl As B4XView = xui.CreatePanel("")
    pnl.SetColorAndBorder(xui.Color_White, 0, 0, 0)
    pnl.SetLayoutAnimated(0, 0, 0, w, 40dip)

    Dim lab As Label
    lab.Initialize("")
    Dim labx As B4XView = lab
    labx.SetTextAlignment("CENTER", "RIGHT")
    labx.Text = text
    pnl.AddView(labx, 5dip, 0, .65 * w, 40dip)
  
    Dim chk As CheckBox
    chk.Initialize("")
    chk.Tag = text
    Dim chkx As B4XView = chk
    pnl.AddView(chkx, .75 * w, 0, .25 *w, 40dip)
    pnl.BringToFront
    CustomListView1.Add(pnl, text)
End Sub

Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    Dim pnl As B4XView = CustomListView1.GetPanel(Index)
    Dim chk As B4XView = pnl.GetView(1)
    If chk.Checked Then
        chk.Checked = False
    Else
        chk.Checked = True
    End If
End Sub


screen1.png
 
Last edited:
Upvote 0
Top