Android Code Snippet xCustomListView Loading Tip

When loading a large CLV list (items derived from a ResultSet - for example), I find it loads much faster if you set the underlying scroll view visibility to False (before loading the list). Set it back to True after populating the the custom list, as follows:

B4X:
ProgressDialogShow2("Updating All Posts...",False)  ' show user the list is being created...   

Cursor = Starter.SQL1.ExecQuery(qry) ' get a subset of the list to load

clvunits.Clear   ' empty the existing xCLV (if any)

' set the underlying xCLV scroll view visibility to false - IMPORTANT - don't waste cycles painting the screen!

clvunits.sv.Visible = False  ' prevent list update (visibility) from consuming extra time in loop processes

Do While Cursor.NextRow
    ' Load many different layouts (possibly)
    ' Set attributes of the layout loaded
    ' call many other methods to set these attributes
    ' do whatever....
Loop

ProgressDialogHide ' dismiss the spinning circle and carry on...

' set the underlying xCLV scroll view visibility to True  - also IMPORTANT
clvunits.sv.Visible = True

Seems that even thou the list being loaded is not within the current screen view, it is still consuming clock cycles - effectively slowing down loading the list.

Hey, I could be wrong, I was once before - once...
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…