B4J Question (Solved) Calculate CustomListView height inside the PreferencesDialog

Solution
This will make it unscrollable:
B4X:
Dim sf As Object = p.ShowDialog(Data(0), "Ok", "Cancel")
Sleep(0)
p.CustomListView1.sv.Height = p.CustomListView1.sv.ScrollViewInnerPanel.Height + 10dip
Wait For (sf) Complete (Result As Int)

aeric

Expert
Licensed User
Longtime User
This trick works in Windows as it applies very fast but it seems there is a delay in Ubuntu Linux where it only applies after closing the dialog (when show for the first time) and open again.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Strange thing happen is when I apply the fix for the cancel button, the issue is not happening.
Check ShowDialog2 sub.

B4X:
Private Sub ShowDialog2 (Action As String, Item As Map)
    If Action = "Add" Then
        PrefDialog2.Dialog.TitleBarColor = xui.Color_RGB(50, 205, 50)
    Else
        PrefDialog2.Dialog.TitleBarColor = xui.Color_RGB(65, 105, 225)
    End If
    PrefDialog2.Title = Action & " Product"
    Dim sf As Object = PrefDialog2.ShowDialog(Item, "OK", "CANCEL")
    Sleep(0)
    PrefDialog2.CustomListView1.sv.Height = PrefDialog2.CustomListView1.sv.ScrollViewInnerPanel.Height + 10dip
    PrefDialog2.CustomListView1.GetPanel(0).GetView(0).Color = xui.Color_Transparent
    PrefDialog2.CustomListView1.sv.ScrollViewInnerPanel.Color = xui.Color_Transparent
    ' Fix Linux UI
    #if B4J
'    Dim btnCancel As B4XView = PrefDialog2.Dialog.GetButton(xui.DialogResponse_Cancel)
'    btnCancel.Width = btnCancel.Width + 20dip
'    btnCancel.Left = btnCancel.Left - 20dip
'    btnCancel.TextColor = xui.Color_Red
'    Dim btnOk As B4XView = PrefDialog2.Dialog.GetButton(xui.DialogResponse_Positive)
'    btnOk.Left = btnOk.Left - 20dip
    #End If  
    Wait For (sf) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        If 0 = Item.Get("id") Then ' New row
            CategoryId = GetCategoryId(Item.Get("Category"))
            Dim ProductMap As Map = CreateMap("code": Item.Get("Product Code"), "name": Item.Get("Product Name"), "price": Item.Get("Product Price"))
            Dim sd As Object = SendData("POST", $"category/${CategoryId}/product"$, ProductMap)
            Wait For (sd) Complete (Data As Map)
            If Data.Get("s") = "ok" Then
                'Log(Data.Get("a")) ' 201 Created
                Dim l As List = Data.Get("r")
                Dim m As Map = l.Get(0)
                xui.MsgboxAsync("New product created!", $"ID: ${m.Get("id")}"$)
            Else
                xui.MsgboxAsync(Data.Get("e"), "Error")
            End If
        Else
            Dim NewCategoryId As Long = GetCategoryId(Item.Get("Category"))
            Dim ProductMap As Map = CreateMap("cat_id": NewCategoryId, "code": Item.Get("Product Code"), "name": Item.Get("Product Name"), "price": Item.Get("Product Price"))
            Dim sd As Object = SendData("PUT", $"category/${CategoryId}/product/${Item.Get("id")}"$, ProductMap)
            Wait For (sd) Complete (Data As Map)
            If Data.Get("s") = "ok" Then
                xui.MsgboxAsync("Product updated!", "Edit")
                CategoryId = NewCategoryId
            Else
                xui.MsgboxAsync(Data.Get("e"), "Error")
            End If
        End If
        GetProducts
    Else
        Return
    End If
End Sub
 

Attachments

  • WebAPIClient.zip
    94.1 KB · Views: 223
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
Maybe this happen only in B4J-Bridge and VM.
I will try it on a physical machine with Ubuntu as main OS and in Release mode.
I run in Ubuntu Linux host (Gnome desktop environment) with B4J-bridge and compiled app with B4JPackager11 still same behavior. It also happen in OpenEuler with UKUI desktop environment inside VM.
 
Upvote 0
Top