Hello there,
i have a little optical problem with a custom list. When i move between pages i want to load data from a sqlite db. In this testcase about 2k rows.
It works technically, but i need ~5 seconds for this operation. While this i see a blank screen, not ideal... When i insert a sleep(0) before the "next" it looks nice, but it takes forever (ten times the normal speed). So, that is not an option. How can i optimize it to look better?
Currently i never see my loading-label, because it´s locking until all items are ready. My first idea was to create a activity only with a loading-bar and reload the rest with a timer. Works... but is not nice. A single sleep before the loop also will not help, i see a blank page without the static header and the loading-info from "list".
I´ve seen "lazy loading" infos, but it looks very complicated and i dont know if this is what i search for to solve it.
Typically i have to load 100-500 items, but it can go up to 5k.
Thanks!
Matze
i have a little optical problem with a custom list. When i move between pages i want to load data from a sqlite db. In this testcase about 2k rows.
B4X:
Sub refreshList(ID As String)
Dim dbRows As ResultSet = database.getAll(ID)
Activity.RemoveAllViews
Activity.LoadLayout("list")
loading.Visible=True 'loading label on the page
Log("begin slowness")
For farmNum = 0 To dbRows.RowCount-1
dbRows.NextRow
Dim fi As viewValue
fi.lbl1 =dbRows.GetString("na")
fi.lbl2 =dbRows.GetString("bi")
fi.lbl3 ="..."
fi.lbl4 ="..."
clv1.Add(createItem(fi),dbRows.GetString("id"))
Next
loading.Visible=False
Log("due")
End Sub
private Sub createItem(t As viewValue) As B4XView
Dim p As B4XView=xui.createpanel("")
p.SetLayoutAnimated(0,0,0,100%x,140dip)
p.SetColorAndBorder(Colors.Transparent,Colors.Transparent,Colors.Transparent,Colors.Transparent)
p.LoadLayout("item")
lbl1.text=t.lbl1
lbl2.text=t.lbl2
lbl3.text=t.lbl3
lbl4.text=t.lbl4
Return p
End Sub
It works technically, but i need ~5 seconds for this operation. While this i see a blank screen, not ideal... When i insert a sleep(0) before the "next" it looks nice, but it takes forever (ten times the normal speed). So, that is not an option. How can i optimize it to look better?
Currently i never see my loading-label, because it´s locking until all items are ready. My first idea was to create a activity only with a loading-bar and reload the rest with a timer. Works... but is not nice. A single sleep before the loop also will not help, i see a blank page without the static header and the loading-info from "list".
I´ve seen "lazy loading" infos, but it looks very complicated and i dont know if this is what i search for to solve it.
Typically i have to load 100-500 items, but it can go up to 5k.
Thanks!
Matze