Hi everyone:
I have a problem populating a listview with pics.
I have an activity with a xCustomListView, when I click in an item
- I start another activity.
- Load a tab layout with two tabs, everyone with a xCustomListview.
- Populate the listview, every item is a small description, and another xCustomlistView (horizontal) where I load the pictures I have in a map, inside a round bitmap.
The problem is when I click an item, the UI freezes for a while, then go a black screen, and then after a few seconds I get the activity with the pics.
I want to show a progress dialog with something like "Reading pics" while the pics are loading, but even the progress dialog is not showing.
I've tried with Wait For, but then just one item is created.
32 items must been created, with 5 or 7 pics every item.
thanks in advance
Activity Checklist
I have a problem populating a listview with pics.
I have an activity with a xCustomListView, when I click in an item
- I start another activity.
- Load a tab layout with two tabs, everyone with a xCustomListview.
- Populate the listview, every item is a small description, and another xCustomlistView (horizontal) where I load the pictures I have in a map, inside a round bitmap.
The problem is when I click an item, the UI freezes for a while, then go a black screen, and then after a few seconds I get the activity with the pics.
I want to show a progress dialog with something like "Reading pics" while the pics are loading, but even the progress dialog is not showing.
I've tried with Wait For, but then just one item is created.
32 items must been created, with 5 or 7 pics every item.
thanks in advance
B4X:
Sub CLVSites_ItemClick (Index As Int, Value As Object)
Dim site As TipoSite
Starter.SiteActual = Value
site = Value
If site.MapFotos.Size = 0 Then
CallSubDelayed2("Starter","ReadPhotos", site)
Else
StartActivity("Checklist")
End If
End Sub
Activity Checklist
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("TabDescription")
TabStrip1.LoadLayout("TabGeneral", "Fotos Generales")
TabStrip1.LoadLayout("TabEspecificas", Starter.SiteActual.TipoInstalacion)
For Each lbl As Label In GetAllTabLabels(TabStrip1)
lbl.Width = 50%x
Next
Starter.csvGeneral = Starter.csv.LoadCSV(File.DirAssets, "Generales.csv", ",")
Starter.csvEspecifico = Starter.csv.LoadCSV(File.DirAssets, Starter.SiteActual.TipoInstalacion & ".csv",",")
PopulateListView(Starter.SiteActual)
End Sub
B4X:
Sub PopulateListView (site As TipoSite)
Dim indice As Int = 0
For Each Row() As String In Starter.csvGeneral
'ProgressDialogShow2("Reading pics " & Row(0), False)
CreateItemChk(Row(0), site.MapFotos.Get(Row(0)), indice)
indice = indice + 1
Next
For Each Row() As String In Starter.csvEspecifico
'ProgressDialogShow2("Reading pics " & Row(0), False)
Wait for (CreateItemChk(Row(0), site.MapFotos.Get(Row(0)), indice)) Complete
indice = indice + 1
Next
ProgressDialogHide
End Sub
Sub CreateItemChk(Punto As String, ListaFotos As List, index As Int) As Panel
Dim p As Panel
p.Initialize("")
Activity.AddView(p, 0, 0, 100%x, ExpandedHeight)
p.SetLayout(0, 0, 100%x, 150dip)
p.LoadLayout("cellPuntosChk")
p.RemoveView
For i = 0 To ListaFotos.Size - 1
Dim pnl As Panel
pnl.Initialize("")
Activity.AddView(pnl, 0, 0, 100%x, ExpandedHeight)
pnl.SetLayout(0, 0, 90dip, 60dip)
pnl.LoadLayout("ImagenPunto")
pnl.RemoveView 'remove from parent
Dim img As B4XBitmap = xui.LoadBitmap(ListaFotos.Get(i))
IVFotoPunto.SetBitmap(CreateRoundBitmap(img, 70dip))
IVFotoPunto.Tag = ListaFotos
pnl.Tag = ListaFotos.Get(i)
CLVFotos.Add(pnl, ListaFotos.Size)
Next
Return p
End Sub