This app show many data at screen and there a lot of labels and customlistviews inside a Dashboard
Each 5 seconds I remove all the views and recreate them with new data.
Most of the time it has the same data, so this process of recreating just make the screen flicker
My question if there is a way to lock the drawing of the screen while I am creating the labels and customlistviews then when ready unlock the screen. When there is no change, the user will not see that everything was destroyed and them rebuilt.
If you remove the views and add new ones at the same time then there shouldn't be any flickering.
Try this code in a new project:
B4X:
Sub Activity_Create(FirstTime As Boolean)
UpdateLabels
End Sub
Sub UpdateLabels
Do While True
Activity.RemoveAllViews
For c = 0 To 9
For r = 0 To 9
Dim lbl As Label
lbl.Initialize("")
Activity.AddView(lbl, c * 40dip, r * 40dip, 35dip, 35dip)
lbl.Text = $"$2.0{c * 10 + r}"$
Next
Next
lbl.Text = DateTime.Now Mod DateTime.TicksPerSecond
Sleep(1000)
Loop
End Sub
Another possible approach is to reuse the existing views instead of replacing them.