Hi expert
i'm trying B4A coming from Appcelerator.
It is very fast and simply
I try to use a scrollview populated from a sqllite db cursor with many records
my scrollview is very slow when loading
For this reason I'm thinking of asynchronous code or other ways
can someone help me please
thank's
the above is my code
Sub AR_Load
Dim ArBitmap As Bitmap
Dim MainPanel As Panel
Dim PanelTop, PanelHeight As Int
Dim progress As Int
Dim Cur as Cursor
Dim Db as SQL
PanelTop = 0
MainPanel = SV_Ar.Panel
MainPanel.Color = Colors.LightGray
db.Initialize(File.DirAssets,"db_sede.db",True)
cur = db.ExecQuery("Select cdar, ar_descrizione from ar")
' this return about 7000 records and is fastest (250 ms)
For i = 0 To 500 ' cur.RowCount - 1 '(only fist 500 records for test)
cur.Position = i
progress = i / 500 * 100
Dim ItemPanel As Panel
Dim ImgAr As ImageView
Dim LblCdAr, LblArDescrizione As Label
LblCdAr.Initialize("")
ArBitmap.Initialize(File.DirAssets,"TREND.png")
ItemPanel.Initialize("")
LblArDescrizione.Initialize("")
PanelHeight = 90dip
MainPanel.AddView(ItemPanel,5dip,PanelTop,SV_Ar.Width,PanelHeight)
ItemPanel.Color = Colors.Black
ItemPanel.AddView(LblCdAr,80dip,8dip,240dip,PanelHeight)
LblCdAr.Color = Colors.Black
LblCdAr.Tag = LblCdAr
LblCdAr.Text = cur.GetString("cdar")
LblCdAr.TextSize = 20
ItemPanel.AddView(LblArDescrizione,80dip,30dip,240dip,30dip)
LblArDescrizione.TextSize = 16
LblArDescrizione.Tag = LblArDescrizione
LblArDescrizione.Text = cur.GetString("ar_descrizione")
ImgAr.Initialize("")
'
ItemPanel.AddView(ImgAr,1dip,5dip,75dip,75dip)
ImgAr.Bitmap = ArBitmap
ImgAr.Gravity = Gravity.FILL
PanelTop = PanelTop + PanelHeight + 1dip
ProgressBar.progress = progress
If i Mod 50 = 0 Then ' refresh progressbar every 50 record
DoEvents
End If
Next
MainPanel.Height=PanelTop
cur.Close
Msgbox("","End Load scrollview")
End Sub
i'm trying B4A coming from Appcelerator.
It is very fast and simply
I try to use a scrollview populated from a sqllite db cursor with many records
my scrollview is very slow when loading
For this reason I'm thinking of asynchronous code or other ways
can someone help me please
thank's
the above is my code
Sub AR_Load
Dim ArBitmap As Bitmap
Dim MainPanel As Panel
Dim PanelTop, PanelHeight As Int
Dim progress As Int
Dim Cur as Cursor
Dim Db as SQL
PanelTop = 0
MainPanel = SV_Ar.Panel
MainPanel.Color = Colors.LightGray
db.Initialize(File.DirAssets,"db_sede.db",True)
cur = db.ExecQuery("Select cdar, ar_descrizione from ar")
' this return about 7000 records and is fastest (250 ms)
For i = 0 To 500 ' cur.RowCount - 1 '(only fist 500 records for test)
cur.Position = i
progress = i / 500 * 100
Dim ItemPanel As Panel
Dim ImgAr As ImageView
Dim LblCdAr, LblArDescrizione As Label
LblCdAr.Initialize("")
ArBitmap.Initialize(File.DirAssets,"TREND.png")
ItemPanel.Initialize("")
LblArDescrizione.Initialize("")
PanelHeight = 90dip
MainPanel.AddView(ItemPanel,5dip,PanelTop,SV_Ar.Width,PanelHeight)
ItemPanel.Color = Colors.Black
ItemPanel.AddView(LblCdAr,80dip,8dip,240dip,PanelHeight)
LblCdAr.Color = Colors.Black
LblCdAr.Tag = LblCdAr
LblCdAr.Text = cur.GetString("cdar")
LblCdAr.TextSize = 20
ItemPanel.AddView(LblArDescrizione,80dip,30dip,240dip,30dip)
LblArDescrizione.TextSize = 16
LblArDescrizione.Tag = LblArDescrizione
LblArDescrizione.Text = cur.GetString("ar_descrizione")
ImgAr.Initialize("")
'
ItemPanel.AddView(ImgAr,1dip,5dip,75dip,75dip)
ImgAr.Bitmap = ArBitmap
ImgAr.Gravity = Gravity.FILL
PanelTop = PanelTop + PanelHeight + 1dip
ProgressBar.progress = progress
If i Mod 50 = 0 Then ' refresh progressbar every 50 record
DoEvents
End If
Next
MainPanel.Height=PanelTop
cur.Close
Msgbox("","End Load scrollview")
End Sub