This is a modification of Erel's xCustomListView version 1.50
It's essentially the same class module, except that some fields, properties and functions were added to handle item selection and enabling, but still keeping all original functionality of xCustomListView in effect.
I decided to work on this to fulfill my personal needs, but I thought it might be useful to somebody else, so here it is.
Regards
Claudio
- CLVItem
Fields:- Color As Int
- Enabled As Boolean
- IsInitialized As Boolean
Tests whether the object has been initialized. - Offset As Int
- Panel As B4XView
- Selected As Boolean
- Size As Int
- TextItem As Boolean
- Value As Object
- Initialize
Initializes the fields to their default value.
- Color As Int
- CLVItem
- xSelectableCustomListView
Events:- ItemClick (Index As Int, Value As Object)
- ItemDeselected (Index As Int, Value As Object)
- ItemDisabled (Index As Int, Value As Object)
- ItemEnabled (Index As Int, Value As Object)
- ItemLongClick (Index As Int, Value As Object)
- ItemRemoved (Index As Int, Value As Object)
- ItemSelected (Index As Int, Value As Object)
- ReachEnd
- ScrollChanged (Offset As Int)
- VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
- AnimationDuration As Int
- DefaultTextBackgroundColor As Int
- DefaultTextColor As Int
- sv As B4XView
- Add (Pnl As B4XView, Value As Object) As String
Adds a custom item. - AddTextItem (Text As Object, Value As Object) As String
Adds a text item. The item height will be adjusted based on the text. - AsView As B4XView
- Class_Globals As String
- Clear As String
Clears all items. - DeselectAll As String
Deselects all items
Items already deselected remain so. - DeselectItem (Index As Int, WithEvent As Boolean) As Boolean
Deselects an individual item
If item is already deselected, it remains so.
Index: Index of item to be deselected
WithEvent: If False then _ItemDeselected event will not be raised
Returns True if item successfully deselected, False otherwise. - DeselectItemList (PanelList As List, WithEvent As Boolean) As List
Deselects a list of items
Returns a list containing their indexes
Items already deselected remain so.
ItemList: A list containing indexes of items to be deselected
If an item could not be deselected, the corresponding item index in the returning list will be -1
WithEvent: If False then _ItemDeselected events will not be raised - DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
Sub DesignerCreateView has been modified
Added code get new custom properties from designer - DisableAll (WithEvent As Boolean) As String
Disables all items
WithEvent: If False then _ItemDisabled events will not be raised - DisableItem (Index As Int, WithEvent As Boolean) As Boolean
Disables an individual item
If item is already disabled it remains so
Index: Index of item to be disabled
WithEvent: If False then _ItemDisabled event will not be raised
Returns True if item successfully disabled, False otherwise - DisableItemList (ItemList As List, WithEvent As Boolean) As List
Disables multiple items
Returns a list containing their indexes
items already disabled remain so.
If as item could not be disabled, the corresponding item index in the returning list will be -1
ItemList: A list containing indexes of items to be disabled
WithEvent: If False then _ItemDisabled events will not be raised - EnableAll (WithEvent As Boolean) As String
Enables all items
WithEvent: If False then _ItemEnabled events will not be raised - EnableItem (Index As Int, WithEvent As Boolean) As Boolean
Enables an individual item
If item already enabled, it remains so
Index: index of item to be enabled
WithEvent: If False then _ItemEnabled event will not be raised
Returns True if item successfully enabled, False otherwise - EnableItemList (ItemList As List, WithEvent As Boolean) As List
Enables multiple items
Returns a list containing their indexes
Items already enabled remain so.
If an item could not be enabled, the corresponding item index in the returning list will be -1
IndexList: A list containing indexes of items to be enabled
WithEvent: If False then _ItemEnabled events will not be raised - FindIndexFromOffset (Offset As Int) As Int
Finds the index of the item (+ divider) based on the offset - getAllItems As List
Returns a list containing all items' indexes - GetBase As B4XView
- getCheckChar As String
Gets or sets check mark character - getCheckColor As Int
Gets or sets check mark color - getCheckFont As Typeface
Gets or sets checkmark typeface - getDividerSize As Float
Gets divider height in DIP - getFirstVisibleIndex As Int
Gets the index of the first visible item. - GetItemFromView (v As B4XView) As Int
Returns the index of the item that holds the given view. - getLastVisibleIndex As Int
Gets the index of the last visible item. - GetPanel (Index As Int) As B4XView
Returns the Panel stored at the specified index. - getSelectedColor As Int
Gets or sets selected items' panel color - getSelectionEnabled As Boolean
Enables or disables UI item selection - getSelItems As List
Returns a list containig all selected items' indexes - getSelSize As Int
Returns number of selected items - getSelSize As Int
- Returns number of selected items
- getShowCheck As Boolean
Gets or sets wheter or not check marks might be shown in selected items' panels - getSize As Int
Returns the number of items. - GetValue (Index As Int) As Object
Returns the value stored at the specified index. - Initialize (vCallBack As Object, vEventName As String) As String
Sub Initialize has been modified
Checkmark initialization code has been added - InsertAt (Index As Int, pnl As B4XView, Value As Object) As String
Adds a custom item at the specified index. - InsertAtTextItem (Index As Int, Text As Object, Value As Object) As String
Inserts a text item at the specified index. - IsItemEnabled (Index As Int) As Boolean
Returns True if item is enabled, False otherwise - IsItemSelected (Index As Int) As Boolean
Returns True if item is selected, False otherwise - IsTextItem (Index As Int) As Boolean
Returns True if item is a text item, False otherwise
- JumpToItem (Index As Int) As String
Scrolls the list to the specified item (without animating the scroll). - RemoveAt (Index As Int) As String
Removes the item at the specified index. - ReplaceAt (Index As Int, pnl As B4XView, PanelHeight As Int, Value As Object) As String
Replaces the item at the specified index with a new item. - ResizeItem (Index As Int, ItemHeight As Int) As String
Changes the height of an existing item. - ScrollToItem (Index As Int) As String
Smoothly scrolls the list to the specified item. - SelectAll As String
Selects all items
items already selected remain so. - SelectItem (Index As Int, WithEvent As Boolean) As Boolean
Selects an individual item
If item is already selected, it remains so.
Index: item to be selected
WithEvent: If False then _ItemSelected event will not be raised
Returns True, if item successfully selected, False otherwise - SelectItemList (IndexList As List, WithEvent As Boolean) As List
Selects a list of items
Returns a list containing their indexes
items already selected remain so.
If a item could not be selected, the corresponding item index in the returning list will be -1
IndexList: A list containing indexes of items to be selected
WithEvent: If False then _ItemSelected events will not be raised - IsInitialized As Boolean
Tests whether the object has been initialized.
- AllItems As List [read only]
Returns a list containing all items' indexes - CheckChar As String
Gets or sets check mark character - CheckColor As Int
Gets or sets check mark color - CheckFont As Typeface
Gets or sets checkmark typeface - SelectedColor As Int
Gets or sets selected items' panel color - SelectionEnabled As Boolean
Enables or disables UI item selection - SelItems As List [read only]
Returns a list containig all selected items' indexes - SelSize As Int [read only]
Returns number of selected items - ShowCheck As Boolean
Gets or sets wheter or not check marks might be shown in selected items' panels - Size As Int [read only]
Returns the number of items.
- xSelectableCustomListView
Attachments
Last edited: