Android Question [Solved] B4XDialog + xcustomlistview

AymanA

Active Member
Licensed User
Hi All,

I need help using customlistview with b4xDialog.

Basically I am using jRDC2 to get some data, and it works fine with also the code for the xcustomlistview (I am reusing the same code in another panel).

But when I try to add the xclustomlistview items to b4xDialog, nothing shows up, the dialog appear but empty the code that I am using is as below.

Thanks for your help in advance!


This is when I create b4xDialog and call the jrdc2 after that:
  Dim p As B4XView = xui.CreatePanel("")

            p.LoadLayout("layout1") --> xclv is on this panel - named CLVS1
            p.SetLayoutAnimated(0, 0, 0, 100%x, 500dip)
               
            Dim diags As B4XDialog
            diags.Initialize(p_mof)
            diags.Title = "x"
           
            Dim rs As ResumableSub = diags.ShowCustom(p,"حفظ","","الغاء")
   
            jRDC_get(code) 'This calls jRDC to reflect items
   
            Wait For (rs) Complete (Result As Int)
            If Result = xui.DialogResponse_Positive Then
             'Something will be done here
End If
Return


This is the jRDC2 call:
Sub jRDC_get (code As String)
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("getitem", Array(code))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
       
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        'work with result
        req.PrintTable(res)
        If res.Rows.Size = 0 Then
            Return
        Else
           
            For Each row() As Object In res.Rows
                Dim username As Object = row(res.Columns.Get("username"))
                Dim app As Object = row(res.Columns.Get("app"))
                Dim usermail As Object = row(res.Columns.Get("user_email"))

                CLVS1.Add(CreateListItemSokan(app,username,usermail, CLVS1.AsView.Width, 200dip), "")
                'Dim p As B4XView = xui.CreatePanel("")
               
            Next
        End If
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
End Sub
 

AymanA

Active Member
Licensed User
Thank you Erel for your reply appreciate it, i have tried also without ResumableSub - only have diags.ShowCustom(p,"حفظ","","الغاء") but same problem, but will review this and make sure i am not missing something, thank you so much!
 
Upvote 0

AymanA

Active Member
Licensed User
I have reviewed the resumableSub mentioned and changed my code to the below but still I have the same problem - empty Dialog:

B4X:
Dim p As B4XView = xui.CreatePanel("")
p.LoadLayout("layout1") --> xclv is on this panel - named CLVS1
p.SetLayoutAnimated(0, 0, 0, 100%x, 500dip)
 
wait for(Get_Sokan_Names_App(code_sokan))  complete (Result As Object) --> I tried also adding the line after the diags.showCustom but same outcome - empty
 
Dim diags As B4XDialog
diags.Initialize(p_mof)
diags.Title = "x"
          
diags.ShowCustom(p,"حفظ","","الغاء")


This is the jRDC2 with resumable sub:
Sub jRDC_get (code As String) as ResumableSub
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("getitem", Array(code))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
      
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        'work with result
        req.PrintTable(res)
        If res.Rows.Size = 0 Then
            Return
        Else
          
            For Each row() As Object In res.Rows
                Dim username As Object = row(res.Columns.Get("username"))
                Dim app As Object = row(res.Columns.Get("app"))
                Dim usermail As Object = row(res.Columns.Get("user_email"))

                CLVS1.Add(CreateListItemSokan(app,username,usermail, CLVS1.AsView.Width, 200dip), "")
                'Dim p As B4XView = xui.CreatePanel("")
              
            Next
        End If
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
    Return Null
End Sub

Apologies if this is incorrect, this is my understanding from the resumablesub, that it will wait for the jRDC2 which I will actually use a lot from now on! but still doesn't solve the problem in my code for the Dialog to show the items in the xclv.
 
Upvote 0

AymanA

Active Member
Licensed User
ok solved now - seems I needed to p.LoadLayout AFTER the Dialog shows not before, once I did that now I can see the items back from xclv

Thank you so much Erel for your help! appreciate it!

Also I have learnt something new and awesome today - resumableSub - thanks a lot!
 
Upvote 0
Top