Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private imgThumbnail As B4XView
Private lblCountry As B4XView
Private clvCountries As CustomListView
Private SQL As SQL
End Sub
Sub AppStart (Form1 As Form, Args() As String)
SQL.InitializeSQLite(GetEnvironmentVariable("DataDir",""),"Flags.db3",False)
MainForm = Form1
MainForm.RootPane.LoadLayout("main")
MainForm.Title = "World Flags"
MainForm.Show
Dim rs As ResultSet = SQL.ExecQuery("SELECT * FROM ISO2 ORDER BY Country")
Dim DefaultHeight As Int = 65dip
Do While rs.NextRow
Dim Buffer() As Byte
Buffer = rs.GetBlob("Thumbnail")
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim bmp As Image
bmp.Initialize2(InputStream1)
Dim p As B4XView = xui.CreatePanel("")
p.Tag = rs.GetString("ISO2code")
p.SetLayoutAnimated(0, 0, 0,clvCountries.AsView.Width, DefaultHeight)
p.LoadLayout("clvItem")
ImgThumbnail.SetBitmap(bmp)
lblCountry.Text = rs.GetString("Country")
clvCountries.Add(p,"")
Loop
End Sub
Sub clvCountries_ItemClick (Index As Int, Value As Object)
Log("This event fires every time as expected")
'What code is required here to expose the cell tag property and lblCountry.Text?
End Sub