Android Question CustomListView Divider Height and color - SOLVED

stevenindon

Active Member
Licensed User
Hello All,

I have been working with CustomListView and would like to know how can i change the CustomListView :

1) Divider Color
2) Divider Height

Programmatically.. *Not in designer's view. Thanks.
 
Solution
Thought there is a work around on this.
Do it yourself ^^
After adding an item, add a panel with a tag for example: "Divider" and if you want to change the settings, just go through the whole list and check for this tag with the value "Divider" and change the size of the panel + the size of the item.

B4X:
For i = 0 To xclv.Size -1
        If "Divider" = xclv.GetValue(i) Then
            Dim PanelDivider As B4XView = xclv.GetPanel(i)
            PanelDivider.Height = 10dip
            xclv.ResizeItem(i,10dip)
        End If
    Next

stevenindon

Active Member
Licensed User
Alexander, Thank you for your feedback on this.

1) xclv.sv.ScrollViewInnerPanel.Color = xui.Color_Blue <<------------- Is perfect!!

2) xclv.DividerSize = 10dip <<<<--------------------------------------- Does not work as it is a read only!!

Still looking for ways to set the divider size.... any more idea?
 
Last edited:
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
2) xclv.DividerSize = 10dip <<<<--------------------------------------- Does not work as it is a read only!!

Still looking for ways to set the divider size.... any more idea?
I've added it as a read-only property. Making it writable is of course possible but is more complicated as you need to move all the views (and I don't think that it will be used too much).
 
Upvote 0

stevenindon

Active Member
Licensed User
Thank you Alexander. Does that mean that there is no way that we can set the divider width programmatically? Thought there is a work around on this.

Anyway Thanks for the info.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Thought there is a work around on this.
Do it yourself ^^
After adding an item, add a panel with a tag for example: "Divider" and if you want to change the settings, just go through the whole list and check for this tag with the value "Divider" and change the size of the panel + the size of the item.

B4X:
For i = 0 To xclv.Size -1
        If "Divider" = xclv.GetValue(i) Then
            Dim PanelDivider As B4XView = xclv.GetPanel(i)
            PanelDivider.Height = 10dip
            xclv.ResizeItem(i,10dip)
        End If
    Next
 
Last edited:
Upvote 0
Solution

William Lancee

Well-Known Member
Licensed User
Longtime User
You could also set divider height to zero in designer and make your own container with two subpanels:
contentPanel and dividerPanel

B4X:
Private Sub Button1_Click
    For i = 0 To 5
        Dim wholePanel As B4XView = makePanel(50dip, 10dip)
        Dim lbl As Label
        lbl.initialize("")
        lbl.Text = "Content " & i
        wholePanel.GetView(0).addview(lbl, 0, 0, wholePanel.Width, 50dip)
        wholePanel.GetView(1).SetColorAndBorder(xui.Color_Black, 0, 0, 0)
        CustomListView1.Add(wholePanel, i)
    Next
End Sub

Private Sub makePanel(contentHeight As Float, dividerHeight As Float) As B4XView
    Dim wholePanel As B4XView = xui.CreatePanel("")
    wholePanel.SetLayoutAnimated(0, 0, 0, CustomListView1.GetBase.Width, contentHeight + dividerHeight)
    Dim contentPanel As B4XView = xui.CreatePanel("")
    wholePanel.AddView(contentPanel, 0, 0, wholePanel.width, contentHeight)
    Dim dividerPanel As B4XView = xui.CreatePanel("")
    wholePanel.AddView(dividerPanel, 0, contentHeight, wholePanel.width, dividerHeight)
    Return wholePanel
End Sub
 
Upvote 0
Top