Android Question Customlistview with CustomLayoutDialog

sigster

Active Member
Licensed User
Hi

I am try to use Customlistview with CustomLayoutDialog

but I can not get the list to customlistview


B4X:
Sub addr_Click
    
    Dim dialog2 As CustomLayoutDialog
    Dim sf As Object = dialog2.ShowAsync("Find", "", "", "", Null, False)
    dialog2.GetButton(DialogResponse.POSITIVE).TextColor = Colors.Black
    dialog2.GetButton(DialogResponse.POSITIVE).TextSize = 20
    dialog2.GetButton(DialogResponse.CANCEL).TextColor = Colors.Black
    dialog2.GetButton(DialogResponse.CANCEL).TextSize = 20
    dialog2.SetSize(40%x, 70%y)
    'Code to change top position
    Dim jo As JavaObject = sf
    Dim window As JavaObject = jo.RunMethodJO("getWindow", Null)
    Dim lp As JavaObject = window.RunMethod("getAttributes", Null)
    lp.SetField("gravity", Bit.Or(Gravity.TOP, Gravity.CENTER_HORIZONTAL))
    lp.SetField("y", 20dip) 'set the top position
    window.RunMethod("setAttributes", Array(lp))
    Wait For Dialog_Ready (DialogPanel As Panel)
    DialogPanel.LoadLayout("address")
    
    For i = 1 To 20
        Dim Streetname As String = "name"
        Cust_listv.Add(CreateListItem(Streetname,Cust_listv.AsView.Width),52dip)
    Next

    
End Sub

Sub CreateListItem(Text As String, Width As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    p.Color = Colors.White

    Dim lbl As Label
    lbl.Initialize("")
    lbl.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    lbl.Text = Text
    lbl.TextColor = Colors.Black
    
    lbl.TextSize = 16
    p.AddView(lbl,55dip,5dip, Width, 36dip)    'view #1
    Return p
End Sub
 

mangojack

Well-Known Member
Licensed User
Are you using the lastest CustomListView ?

this will work ...
B4X:
Sub CreateListItem(Text As String, Width As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    Activity.AddView(p,0,0,Width,52dip)
    p.Color = Colors.White
    p.RemoveView





But you should use the the latest xCLV with XUI lib (both internal libs if you are using a recently current version of B4A)
B4X:
Cust_listv.Add(CreateListItem(Streetname,Cust_listv.AsView.Width, 52dip),value)

Sub CreateListItem(Text As String, Width As Int, Height as Int) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, Height)
    '..................


**Edit

If you are using the Current xClv you are passing a dip value as theClv.Add () retun value
B4X:
Cust_listv.Add(CreateListItem(Streetname,Cust_listv.AsView.Width),52dip)

Plus the updated CreateListItem code above...
 
Last edited:
Upvote 0

sigster

Active Member
Licensed User
Thanks

Yes I am using latest CustomListView

tell me using Customlistview with CustomLayoutDialog in itemclick then I need to select twice for the first time before I get the item to LOG


B4X:
Dim xlistvAddress As B4XView = Cust_listv.GetPanel(Index).GetView(1)
    Log(xlistvAddress.Text)
 
Upvote 0
Top