This class allows you to manage two lists (available and selected) with a display based on CustomListView and advanced features such as multiple selection and drag and drop of elements.
Internal Structure
Main Variables:
Main features
List management:
Multiple selection:
Drag and drop:
Action buttons:
Internal Structure
Main Variables:
AviableList and SelectedList: the source lists.
clvAvailable and clvSelected: the two CustomListViews displaying the items.
Aviable_SelectedValue and Selected_SelectedValue: the currently selected values.
CSelections_a and CSelections_s: selection handlers (CLVSelections class).
Drag & Drop Management: DragGhost, DragValue, DragSource, etc.
Initialization :Initialize(Callback As Object, EventName As String) : Standard signature for a B4X class.
Setup(Container As B4XView, RootPane As B4XView) : class configuration with container and window root.
Main features
List management:
SetAvailableList(lst As List): loads a list into the "available" section.
MoveItem(...): moves an item from one list to another.
Multiple selection:
ToggleSelection(values As List, selections As CLVSelections, index As Int, value As String): adds or removes an element from the selection.
Drag and drop:
dragitem_MousePressed, dragitem_MouseDragged, dragitem_MouseReleased: manage the creation of a visual "ghost" and the movement of items between lists.
Action buttons:
btn_AviableToSelected_Click and btn_SelectedToAviable_Click: transfer the selected items from one list to the other.
btAccept_MouseClicked: returns the final list of selected items to the main page via CallSubDelayed2.
Example of use:In your main code, you initialize and configure the class as follows:
Use::
slv.Initialize(Me, "NewList")
slv.Setup(Pane1, B4XPages.MainPage.Root)
slv.SetAvailableList(AviableList)
...
Sub NewList(mList As List)
Log("List received : " & mList)
End Sub