B4i Library [class] CustomListView

Erel

Administrator
Staff member
Licensed User


B4i implementation of CustomListView (http://www.basic4ppc.com/android/forum/threads/class-customlistview-a-flexible-list-based-on-scrollview.19567/#content).

Note that you should make sure that there is a live reference to all instances of CustomListView. Otherwise the instance will be released and the events will not be raised.

You can use a global variable to store a live reference.

New version was uploaded. CustomListView is implemented as a custom view. It should be added with the designer.

V1.76 uploaded. This update brings the improvements added to B4A CustomListView:
- Animated inserts.
- ResizeItem method.
- FirstVisibleIndex / LastVisibleIndex properties.
- ScrollToItem.
- ReachEnd event.
- RemoveAt / ReplaceAt methods.

The class will be included as a library in B4i v4.30.
 

Attachments

Last edited:

hzchrisfang

Member
Licensed User
Hi, awesome Erel, could you please add longclick event into CustomListView ? And how to recognize swipe gestures ?
 
Last edited:

Erel

Administrator
Staff member
Licensed User
Add this sub to add long click. Adding swipe gestures is more complicated.
B4X:
Private Sub Panel_LongClick
   Dim p As Panel = Sender
   p.GetView(0).Color = HighlightColor
   p.GetView(0).SetColorAnimated(700, Colors.Transparent)
   CallSub3(CallBack, EventName & "_ItemLongClick", p.Tag, items.Get(p.Tag))
End Sub
 

hzchrisfang

Member
Licensed User
I have add LongClick sub into my app. But when I take long press on my phone, it produce a multiple LongClick event response, how could this be?
 

Erel

Administrator
Staff member
Licensed User
It is a bug related to LongClick event. It is fixed for the next update which will be released later today.
 

LucaMs

Expert
Licensed User
I have add LongClick sub into my app. But when I take long press on my phone, it produce a multiple LongClick event response, how could this be?
In the meantime, you could use a boolean variable at module level, check and set it in the event, so as not to repeat it.
 

stobi

New Member
Licensed User
Is the pull to refresh feature available in this B4I version ?
Also I'm Looking for a possibility to allow the User to reorder the list items. Is this possible?
 

Erel

Administrator
Staff member
Licensed User
Both features are not implemented. You will need to modify the class to support them.
 

stobi

New Member
Licensed User
As I'm new to B4I I don't think I'm able to implement this functionality ...
Will these features be available once the default iOS ListView will be implemented ?
 

Erel

Administrator
Staff member
Licensed User
Almost the same code as in B4A:
B4X:
Sub sv_ScrollChanged (OffsetX As Int, OffsetY As Int)
   If OffsetY + sv.Height >= sv.Panel.Height Then
     If DateTime.Now > lastAddItemsTime + 200 Then
       lastAddItemsTime = DateTime.Now
       CallSub(CallBack, EventName & "_AddItems")
     End If
   End If
End Sub
Add to Class_Globals:
B4X:
  Private lastAddItemsTime As Long
Main module:
B4X:
Sub clv1_AddItems
  Log("AddItems")
  For i = 1 To 20
  clv1.AddTextItem(i, i)
  Next
End Sub
 

Alberto Michelis

Active Member
Licensed User
Hi, I have a customlistview and
1) when I add more lines than the screen height, I scrooll the list till the end, and, the last item is always showed at half its height.
How to solve this?
2) any way to sort the list by any of its line components?
How?

Thanks
 

ilan

Expert
Licensed User
CustomListView is implemented as a custom view. It should be added with the designer.
Does it means that we need to change old projects where we added the clv in our code and not via designer? (If we use the new class)
 

Erel

Administrator
Staff member
Licensed User
Yes. However you can keep the old implementation and only use the new implementation in new projects.
 
Top