Attached code works fine on B4A & B4J but is not compatible with B4I as map.GetKeyAT & map.GetValueAt does not exist.
This code is used to fill a CLV
I'm not sure how else to cycle though my database returning in this case the Manufacturer name and ManufacturerID
I start with determining number of rows with 4 image views and labels per row and creating blanks at the end if I cannot fill the row.
This code is used to fill a CLV
I'm not sure how else to cycle though my database returning in this case the Manufacturer name and ManufacturerID
I start with determining number of rows with 4 image views and labels per row and creating blanks at the end if I cannot fill the row.
B4X:
Do While rs.NextRow
makeList.Put(rs.GetString("MakeName"),rs.GetLong("MakeID"))
Loop
rs.Close
CachedPanels.Initialize
Dim rows As Int = makeList.Size/4 ' number of makes / 4
Dim remainder As Int = makeList.Size Mod 4 ' if does not divide by four then add 1 more row
If remainder > 0 Then
rows = rows + 1
End If
Dim counter As Int = makeList.Size
Dim makeCounter As Int = 0
For i = 1 To rows
If counter > 3 Then
makeList.
Dim id1 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter),makeList.GetValueAt(makeCounter))
Dim id2 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter+1),makeList.GetValueAt(makeCounter+1))
Dim id3 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter+2),makeList.GetValueAt(makeCounter+2))
Dim id4 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter+3),makeList.GetValueAt(makeCounter+3))
counter = counter - 4
makeCounter = makeCounter + 4
Else
If counter = 3 Then
Dim id1 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter),makeList.GetValueAt(makeCounter))
Dim id2 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter+1),makeList.GetValueAt(makeCounter+1))
Dim id3 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter+2),makeList.GetValueAt(makeCounter+2))
Dim id4 As ImageData = CreateItem2("",0)
counter = counter - 3
makeCounter = makeCounter + 3
'id4.Title = ""
'id4.Bitmap = Null
End If
If counter = 2 Then
Dim id1 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter),makeList.GetValueAt(makeCounter))
Dim id2 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter+1),makeList.GetValueAt(makeCounter+1))
Dim id3 As ImageData = CreateItem2("",0)
Dim id4 As ImageData = CreateItem2("",0)
counter = counter - 2
makeCounter = makeCounter + 2
'id4.Title = ""
'id3.Title = ""
'id4.Bitmap = Null
'id3.Bitmap = Null
End If
If counter = 1 Then
Dim id1 As ImageData = CreateItem2(makeList.GetKeyAt(makeCounter),makeList.GetValueAt(makeCounter))
Dim id2 As ImageData = CreateItem2("",0)
Dim id3 As ImageData = CreateItem2("",0)
Dim id4 As ImageData = CreateItem2("",0)
counter = counter - 1
makeCounter = makeCounter + 1
'id4.Title = ""
'id4.FileName = ""
'id3.FileName = ""
'id2.FileName = ""
'id3.Title = ""
'id2.Title = ""
End If
End If
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, clvMakes.AsView.Width, 110dip)
clvMakes.Add(p, Array As ImageData(id1, id2, id3, id4))
Next