B4A Library [Lib] UltimateListView

I've been working on this project for a long time and I'm very proud to release the version 4 today.

The UltimateListView is, as its pompous name says, THE ListView.

  • It can handle very long lists. This is a screenshot of a list with 245813 items, all different:

    verylonglist.jpg


  • It can mix different layouts (and they can be changed dynamically). You can use it as an expandable ListView:

    layouts.jpg


  • It has a low memory footprint and is very fast (this report comes from the Performance demo where the list has to display 128901 distinct words read from a database and the used device is a Huawei Honor single core 1.4 Ghz):

    performance.png


  • It can scroll in both directions thanks to its swipe detector:

    tables.jpg


  • The swipe detector can also be used to implement a swipe-to-dismiss or a swipe-to-reveal:

    swipedetector.png
  • You can easily add editors to your table to change its content:

    celledit.jpg


  • You can animate the items when they are added, removed, replaced or when the list is scrolled (with your own custom animation):

    animationclap.png


  • It can stack items from the bottom:

    stackfrombottom.png


  • It supports drag & drop operations (internal & external):

    dragndrop.png


  • You can synchronize lists with different item heights:

    grid.jpg
The examples will show you how to implement a Pull-to-Refresh, create sticky headers or combine several lists to make a wheel. One of the examples is an improved version of my File Explorer class.

All texts and images can be loaded asynchronously (from Internet, from a database or from a local folder), so you can scroll even if the data are not fully loaded.

The list has its own state manager.

Since September 2018, ULV is available for free. You can still donate for it if you wish.
To send the money, just click on the Donate button below (the amount to enter is in euros):


Note that UltimateListView is not a wrapper around the work of someone else. It is 100% my own code and it is based upon the standard Java ListView of Android.

The UltimateListView does not work with Android versions < 2. It cannot work with B4J or B4i.

Current version: 4.50

DOWNLOAD HERE:
 
Last edited:

ilan

Expert
Licensed User
Longtime User
hi, can i add this animation to ULV?


or just scale a panel to 0 with SetLayoutAnimated

if i try to add an animation to a panel i am getting an error.

i know that i should not try to update the views directly and that ulv works different then clv where i need to update the list with all content and then just rebuild ulv again and call ulv.refreshcontent but how could i still do such an animation with ulv??

thanx

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 504 (Main)
java.lang.ClassCastException: android.widget.AbsListView$LayoutParams cannot be cast to anywheresoftware.b4a.BALayout$LayoutParams
at anywheresoftware.b4a.objects.ViewWrapper.SetLayoutAnimated(ViewWrapper.java:337)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:19)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1680)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
** Activity (main) Pause, UserClosed = true **
 

Informatix

Expert
Licensed User
Longtime User
hi, can i add this animation to ULV?


or just scale a panel to 0 with SetLayoutAnimated

if i try to add an animation to a panel i am getting an error.

i know that i should not try to update the views directly and that ulv works different then clv where i need to update the list with all content and then just rebuild ulv again and call ulv.refreshcontent but how could i still do such an animation with ulv??

thanx
1) Support is only provided by email.
2) Please look at the Animation and Drag&Drop examples.
 

PHB2

Member
Licensed User
Longtime User
Hi Informatix

Very keen on your library. Can I ask a couple of questions?

Can I confirm it allows for swipe left and swipe right, with the ability to have content behind the swipped panel similar to in Mail where you can swipe left and see in green 'Archive' and when you swipe right you can see in red 'Delete' ?
Can you long press an item and move it elsewhere in the list?
Does it come with example code?
Can you add Views to the item panel, e.g. could I add a button to each item that can be clicked and raise an event?

If the answer is yes to all the above questions, you have another customer :)

Regards

Mark
 

Informatix

Expert
Licensed User
Longtime User
Hi Informatix

Very keen on your library. Can I ask a couple of questions?

Can I confirm it allows for swipe left and swipe right, with the ability to have content behind the swipped panel similar to in Mail where you can swipe left and see in green 'Archive' and when you swipe right you can see in red 'Delete' ?
Can you long press an item and move it elsewhere in the list?
Does it come with example code?
Can you add Views to the item panel, e.g. could I add a button to each item that can be clicked and raise an event?

If the answer is yes to all the above questions, you have another customer :)

Regards

Mark
As Fredo said, it's a big Yes.
 

Informatix

Expert
Licensed User
Longtime User
I published yesterday a library named Observable. In case anyone wonders, it is of little use to ULV. For example, it is not possible to use the Bind function of Observables because of the view recycling.
You can write a cleaner code with it, but this can be achieved also without the library. Example:
B4X:
Sub Item_RowContentFiller(RowID As Long, LayoutName As String, CellPanel As Panel, CellIndex As Byte, Position As Int)
   Select CellIndex
       Case 0:
           'Positions the cursor on the requested item
           dbCursor.Position = RowID

           'Retrieves the image from the database
           Dim binImage() As Byte, Flux As InputStream
           binImage = dbCursor.GetBlob("Image")
           Flux.InitializeFromBytesArray(binImage, 0, binImage.Length)
           Dim Bmp As Bitmap
           Bmp.Initialize2(Flux)
           Flux.Close

           'Displays the bitmap
           Dim IV As ImageView = CellPanel.GetView(0)
           IV.Bitmap = Bmp
           IV.Gravity = Gravity.FILL

       Case 1:
           'Displays the name
           Dim lbl As Label = CellPanel.GetView(0)
           lbl.Text = dbCursor.GetString("Name")

       Case 2:
           'Reads the origin and sets a string for display
           Dim Origin As String
           If dbCursor.GetInt("Exotic") = 0 Then
               Origin = "native"
           Else
               Origin = "exotic"
           End If

           'Displays the origin
           Dim lbl As Label = CellPanel.GetView(0)
           lbl.Text = Origin

       Case 3:
           'Displays the quantity
           Dim lbl As Label = CellPanel.GetView(0)
           lbl.Text = dbCursor.GetInt("Quantity")
   End Select
End Sub
This code could be written like this with Observables:
B4X:
Sub Item_RowContentFiller(RowID As Long, LayoutName As String, CellPanel As Panel, CellIndex As Byte, Position As Int)
   Select CellIndex
       Case 0:
           'Displays the bitmap
           Dim IV As ImageView = CellPanel.GetView(0)
           IV.Bitmap = ofImage.GetValueForID(RowID)
           IV.Gravity = Gravity.FILL

       Case 1:
           'Displays the name
           Dim lbl As Label = CellPanel.GetView(0)
           lbl.Text = ofName.GetValueForID(RowID)

       Case 2:
           'Displays the origin
           Dim lbl As Label = CellPanel.GetView(0)
           lbl.Text = ofOrigin.GetValueForID(RowID)

       Case 3:
           'Displays the quantity
           Dim lbl As Label = CellPanel.GetView(0)
           lbl.Text = ofQty.GetValueForID(RowID)
   End Select
End Sub

Sub Fruits_ReadFromDB(ID As Object) As Object
   If ID <> Null Then
       dbCursor.Position = ID
       Dim oField As ObservableField = Sender
       If oField = ofImage Then
           'Retrieves the image from the database
           Dim binImage() As Byte, Flux As InputStream
           binImage = dbCursor.GetBlob("Image")
           Flux.InitializeFromBytesArray(binImage, 0, binImage.Length)
           Dim Bmp As Bitmap
           Bmp.Initialize2(Flux)
           Flux.Close
           Return Bmp
       Else If oField = ofName Then
           'Retrieves the name from the database
           Return dbCursor.GetString("Name")
       Else If oField = ofOrigin Then
           'Retrieves the origin from the database
           If dbCursor.GetInt("Exotic") = 0 Then
               Return "native"
           Else
               Return "exotic"
           End If
       Else If oField = ofQty Then
           'Retrieves the quantity from the database
           Return dbCursor.GetInt("Quantity")
       End If
   End If
   Return Null
End Sub
The same result could be achieved with this code:
B4X:
Sub Item_RowContentFiller(RowID As Long, LayoutName As String, CellPanel As Panel, CellIndex As Byte, Position As Int)
   Select CellIndex
       Case 0:
           'Displays the bitmap
           Dim IV As ImageView = CellPanel.GetView(0)
           IV.Bitmap = GetValueForField("Image", RowID)
           IV.Gravity = Gravity.FILL

       Case 1:
           'Displays the name
           Dim lbl As Label = CellPanel.GetView(0)
           lbl.Text = GetValueForField("Name", RowID)

       Case 2:
           'Displays the origin
           Dim lbl As Label = CellPanel.GetView(0)
           lbl.Text = GetValueForField("Exotic", RowID)

       Case 3:
           'Displays the quantity
           Dim lbl As Label = CellPanel.GetView(0)
           lbl.Text = GetValueForField("Quantity", RowID)
   End Select
End Sub

Sub GetValueForField(Field As String, ID As Long) As Object
   dbCursor.Position = ID
   If Field = "Image" Then
       'Retrieves the image from the database
       Dim binImage() As Byte, Flux As InputStream
       binImage = dbCursor.GetBlob(Field)
       Flux.InitializeFromBytesArray(binImage, 0, binImage.Length)
       Dim Bmp As Bitmap
       Bmp.Initialize2(Flux)
       Flux.Close
       Return Bmp
   Else If Field = "Name" Then
       'Retrieves the name from the database
       Return dbCursor.GetString(Field)
   Else If Field = "Exotic" Then
       'Retrieves the origin from the database
       If dbCursor.GetInt(Field) = 0 Then
           Return "native"
       Else
           Return "exotic"
       End If
   Else If Field = "Quantity" Then
       'Retrieves the quantity from the database
       Return dbCursor.GetInt(Field)
   End If
   Return Null
End Sub
 

cimperia

Active Member
Licensed User
Longtime User
Wow, thank you. I've been using your excellent ULV library. I'll take the opportunity to visit your ProBundle library.

What prompted you to make this generous offer?
 
Last edited:

npsonic

Active Member
Licensed User
Starting from September, ULV and most of the ProBundle libraries will be available for free. You can still donate for them if you wish.
Will you share source code for all libraries? Without the source code it's kind of dangerous or impossible to use libs created by others in projects that are published in play store as there is no updates in case of problems.
 

Star-Dust

Expert
Licensed User
Longtime User
Will you share source code for all libraries? Without the source code it's kind of dangerous or impossible to use libs created by others in projects that are published in play store as there is no updates in case of problems.
You're wrong, otherwise you should buy the sources of all the libreries. When a library is abandoned, 2 of them are the same or better.
However, most of the libraries in this forum are always supported and @Informatix gives excellent assistance.
 
Last edited:

npsonic

Active Member
Licensed User
You're wrong, otherwise you should buy the sources of all the libreries. When a library is abandoned, 2 of them are the same or better.
However, most of the libraries in this forum are always supported and @informatrix gives excellent assistance.
I don't know what libs are you referring to, but at least 50% of libs in forum are created and there is no support after that.
If source code is not shared with the lib you would just take a risk with the future problems and possibility that you have to create whole lib your self if it's important part of your app.

I know nothing about situation of Informatix, but support for paid libs are most certainly not the same as libs shared free.
 
Top