Hello, Why this code partially works?
When a codition enter, the text colors it's changed but it will applied for the whole loop even if code value is changes, instead defaulticon works fine.
Thank you
When a codition enter, the text colors it's changed but it will applied for the whole loop even if code value is changes, instead defaulticon works fine.
B4X:
Sub Globals
Dim color as int
Dim ListView1 As ListView
Dim defaulticon, white, green, yellow, blue, red, violet As Bitmap
End sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
'db stuff
white=LoadBitmap(File.DirAssets,"whitedot.png")
green=LoadBitmap(File.DirAssets,"greendot.png")
blue=LoadBitmap(File.DirAssets,"bluedot.png")
red=LoadBitmap(File.DirAssets,"reddot.png")
violet=LoadBitmap(File.DirAssets,"violetdot.png")
End sub
Sub load_click
Try
SQL1.BeginTransaction
c = SQL1.ExecQuery("SELECT code FROM codes LIMIT 80")
For i = 0 To c.RowCount - 1
c.Position = i
Dim code As Double
code = (c.GetDouble("code")) 'codes > 2, 1.1, 2.3, 5.9, 1.9, 2.3, 4.6
If code < 2 Then
colore = Colors.White
defaulticon = white
Else If code > 2 Then
colore = Colors.Magenta
defaulticon = green
Else if code > 3 Then
colore = Colors.Blue
defaulticon = blue
Else If code > 4 AND magnitude < 6 Then
colore = Colors.Red
defaulticon = red
End If
ListView1.TwoLinesAndBitmap.Label.TextColor = colore
ListView1.AddTwoLinesAndBitmap..............
'Listview settings
Next
SQL1.TransactionSuccessful
Catch
Log(LastException.Message)
End Try
SQL1.EndTransaction
End Sub
Thank you