CustomListView - A flexible list based on ScrollView

Status
Not open for further replies.

LucaMs

Expert
Licensed User
Longtime User
About the divider line...

I don't get dividers when I add my custom item. So I opened the example and it seems to me that you get the divider (second CLV) by placing the views not on top (layout).
If you add a simple text item (AddTextItem) it seems that the dividerHeight is used.

Is it so?


[BTW in InsertAtTextItem there is a literal 2dip]
 

LucaMs

Expert
Licensed User
Longtime User
It seems to me that there is a bug.

To demonstate it, I'm attaching a small project (sizes are set for my tablet, in portrait mode, sorry :)).

On Activity creation, I add 2 items; then, in the Button1 click event, I remove them and add 2 new items (identical).
Clickng several times you will see that the position of the new second item will be wrong.


P.S. Replaced the CLV with the new and original version 1.76 (same bug).
 

Attachments

  • CLV Test.zip
    11 KB · Views: 429
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that you don't need this designer script line:
B4X:
CustomListView1.SetTopAndBottom(0, Button1.Top - 4dip)
Just set the vertical anchors to BOTH.

The issue is fixed for the next update. It happens when you call RemoveAt and remove the last item. Change RemoveAt code to:
B4X:
Public Sub RemoveAt(Index As Int)
   If GetSize <= 1 Then
     Clear
     Return
   End If
   Dim removePanel, p As Panel
   removePanel = panels.Get(Index)
   For i = Index + 1 To items.Size - 1
     p = panels.Get(i)
     p.Tag = i - 1
     Dim NewTop As Int = p.Top - heights.Get(Index) - dividerHeight
     p.top = NewTop
   Next
   sv.Panel.Height = sv.Panel.Height - heights.Get(Index) - dividerHeight
   items.RemoveAt(Index)
   panels.RemoveAt(Index)
   heights.RemoveAt(Index)
   removePanel.RemoveView
End Sub
 

LucaMs

Expert
Licensed User
Longtime User
Can these be useful?

B4X:
Public Sub GetItemFromValue(Value As Object) As Int
    Return items.IndexOf(Value)
End Sub

Public Sub GetPanelFromValue(Value As Object) As Panel
    Dim pnl As Panel
    Dim idx As Int = items.IndexOf(Value)
    If idx > - 1 Then
        pnl = panels.Get(idx)
    End If
    Return pnl
End Sub
 

LucaMs

Expert
Licensed User
Longtime User
If they are useful for you then add them.
Are you sure? :D

1. You assume that all values are unique. This may not be the case.
Yes, but there may be some cases (user rankings).
Otherwise, the method (or a v.2) could return a list of panels.

2. CustomListView will not be updated any more. It is replaced with xCustomListView.
I had forgotten to have read this "new CLV"; I will add these posts to that thread (I'm kidding :)).
 

sseaand

Member
Licensed User
Longtime User
How to disable ItemClick event from this panel?
 

Attachments

  • 2017-10-19_091522.png
    2017-10-19_091522.png
    5 KB · Views: 424
Status
Not open for further replies.
Top