B4A Library [B4X] CLVSelections - extended selection modes for xCustomListView

This class extends xCustomListView library and adds more selection modes:

MODE_SINGLE_ITEM_TEMP - The same as the default behavior.
MODE_SINGLE_ITEM_PERMANENT - Single item is selected and the selection remains.
MODE_MULTIPLE_ITEMS- Multiple items can be selected.

There is also a helper method that selects an item and makes it visible.

Usage:

Initialize a CLVSelections object and set the selection mode:
B4X:
CSelections.Initialize(CustomListView1)
CSelections.Mode = CSelections.MODE_MULTIPLE_ITEMS

Implement the ItemClick event:
B4X:
Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    CSelections.ItemClicked(Index)
End Sub

If using lazy loading then also call from VisibleRangeChanged (at the end):
B4X:
CSelections.VisibleRangeChanged(FirstIndex, LastIndex)

Depends on B4XCollections, xCustomListView and XUI libraries.

B4J example is attached. The class is included inside.
 

Attachments

  • CLVSelections.zip
    3.8 KB · Views: 1,341

LucaMs

Expert
Licensed User
Longtime User
Erel, I made a couple of changes to this class of yours:

B4X:
'v1.00
'v.1.10 (lm)    Added selection of a single permanent item by pressing the arrow keys (B4J)
'               and the CLV scrolling required for the selected item to be fully visible.
(I hope the comment above is exhaustive).

I am sure that I have not compromised your code and that my version is compatible with yours.

You can easily find my changes (mostly (maybe only) Subs/Lines added) by searching:
B4X:
'LM - 08/08/2024

I would much rather you post mine as your own than for me to rename the class and post it (please read this).


[BTW These changes were much less simple than I imagined; or, more likely, I just got too old ? ]




 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
I don't see your file
I have not attached it, waiting for your answer.
I do not think it is better for me to publish it with a different name, having N very similar classes creates embarrassment in the choice and the official ones (i.e. yours) are trusted more.

Anyway, I will do as you say, if you do not change your opinion.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…