B4A Library [B4X] PreoptimizedCLV - Lazy loading extension for xCustomListView

MrKim

Well-Known Member
Licensed User
Longtime User
Also, I have one wish for all of this. A filter on CLV. The list I am implimenting all of this on is a problem not because the list is large, But it is constantly being refreshed - usually from the same 3-6 sources with maybe 1000 total items. It would be much better (and reduce network traffic) if I could load all thousand items and then filter the list for the desired items.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can disable the fast scrollbar and show the regular bar.
PCLV.ShowScrollBar = False

And ScrollBar Visible in the designer.

BBCodeView itself is based on ScrollView so I'm not sure that it is the best idea to combine them. It depends on your usage. BBLabel is not based on ScrollView.

Don't use the Tag property at all. Store everything you need in the Value object.
 

MrKim

Well-Known Member
Licensed User
Longtime User
You can disable the fast scrollbar and show the regular bar.
PCLV.ShowScrollBar = False

And ScrollBar Visible in the designer.
Did that. Cleaned the project. It had no effect. See picture in previous post. BOTH scrollbars are there but neither one works although PCLV scrolllbar does track the location when scrolling with the mouse. This is a showstopper.
This is B4J. Should I post in that forum instead of here?

Don't use the Tag property at all. Store everything you need in the Value object.
That works fine for CLV_ItemClick but I don't know how to access Value in the DragDetected event so I also stored the Map in the BBLabel Tag which I can retrieve with Sender in DragDetected.
Does not work
B4X:
Sub UnSchedOpsList_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)

    For Each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex)
        Dim item As CLVItem = UnSchedOpsList.GetRawListItem(i)
        'Create the layout for item i and add it to item.Panel.
        Dim M As Map = item.Value
        Dim P As B4XView = xui.CreatePanel("UnschOPs")', TE As BCTextEngine
        Dim DT As String = M.Get("Os_StartbyDate")
        If DADMod.Isnull(DT) Then DT = "N/A" Else DT = DT.SubString2(0, 5)
        P.Tag = M
        P.LoadLayout("BBLabel")
        M.Put("BBLbl", P.GetView(0).Tag)
        TextEngine.Initialize(P)
        UnschOPsBB.Text = ScheduleMod.CheckForLate(M.Get("Os_StartbyDate"), 3) & $"  [Color=blue][b][u]"$ & M.Get("Os_JobNum") & $"[/u][/b][/Color] / [Color=black][b][u]"$ & M.Get("Os_ReleaseNum") & $"[/u][/b][/Color] Op [Color=#0000ff][b][u]"$ & M.Get("Os_SeqNum") & $"[/u][/b][/Color]"$
        item.Panel.AddView(P, 0, 0, 300, 50)
        DandD1.MakeDragSource(item.Panel, "DandD1")
        UnschOPsBB.Tag = M   '.Get("Os_ID")
    Next
End Sub

Sub DandD1_DragDetected(e As MouseEvent)
    Log("DandD1 Drag Detected : Starting drag")
Try
        Dim BB As BBLabel = Sender
        Dim M As Map = BB.Tag
        DandD1.SetDragModeAndData2(TransferMode.ANY, Array As String("AddNewJob", "Os_ID", "Data", "JobIndex", "Os_WCCode"), Array As Object("AddNewJob", M.Get("Os_ID"), "Os_ID", NumberFormat(ActiveLV.GetItemFromView(DandDCtl.mBase), 1, 0), M.Get("Os_WCCode")),  BB.mBase.Snapshot)
Catch
        Log("DandD1_DragDetected" & CRLF & LastException.Message)
End Try

End Sub
The code above starts the drag and drop OK but I have no idea how to retrieve the information I need to continue in DandD1_DragDetected.
Logging Sender gives me
B4X:
DandD1 Drag Detected : Starting drag
(draganddrop) [fx=anywheresoftware.b4j.objects.JFX@f40baf, mode=java.lang.Object@3e558d, dataid=[Ljava.lang.String;@bf429a
, dataobject=[Ljava.lang.Object;@b41f5d, dragboardimg=(Image) Not initialized, dragboardimgoffsetx=0.0
, dragboardimgoffsety=0.0, startdrag=false, callback=class com.stevel05.draganddrop.main
, seventname=DandD1, teventname=DandD1, dateutils=null
, cssutils=null, main=null, dadmod=null
, schedulemod=null, transfermode=null, httputils2service=null
, b4xcollections=null]

BBCodeView itself is based on ScrollView so I'm not sure that it is the best idea to combine them. It depends on your usage. BBLabel is not based on ScrollView.
I am not using BBCodeView so I am not sure what you are referring to here. Combine with what?

Thanks
Kim
 
Last edited:

MrKim

Well-Known Member
Licensed User
Longtime User
I solved the scrollbar issue.
B4X:
       PCLV.ShowScrollBar = False

MUST come AFTER
B4X:
    PCLV.Initialize(Me, "PCLV", UnSchedOpsList)
 

beltrao73

Member
Licensed User
Longtime User
Hi,
Is it possible to combine PreoptimizedCLV and CLVExpandable?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…