Any way to consolidate the code in ShowPics SUB?
Seems like a lot of redundant code...already put the images in an array....actually 4 of them...any thoughts? thanks in advance
Seems like a lot of redundant code...already put the images in an array....actually 4 of them...any thoughts? thanks in advance
B4X:
Sub globals
Dim imgP1() As ImageView
Dim img15P1, img16P1, img17P1, img18P1, img19P1, img20P1, img25P1 As ImageView
Dim imgP2() As ImageView
Dim img15P2, img16P2, img17P2, img18P2, img19P2, img20P2, img25P2 As ImageView
Dim imgP3() As ImageView
Dim img15P3, img16P3, img17P3, img18P3, img19P3, img20P3, img25P3 As ImageView
Dim imgP4() As ImageView
Dim img15P4, img16P4, img17P4, img18P4, img19P4, img20P4, img25P4 As ImageView
.....
Sub Activity_Create(FirstTime As Boolean)
......
imgP1 = Array As ImageView(img20P1, img19P1, img18P1, img17P1, img16P1, img15P1, img25P1)
imgP2 = Array As ImageView(img20P2, img19P2, img18P2, img17P2, img16P2, img15P2, img25P2)
imgP3 = Array As ImageView(img20P3, img19P3, img18P3, img17P3, img16P3, img15P3, img25P3)
imgP4 = Array As ImageView(img20P4, img19P4, img18P4, img17P4, img16P4, img15P4, img25P4)
For i = 0 To 6
imgP1(i).visible = False
imgP2(i).visible = False
imgP3(i).visible = False
imgP4(i).visible = False
Next
......
Sub ShowPics
Dim tm, pm As Int
For tm = 1 To 7
For pm = 1 To 4
Select pm
Case 1
If arrScores(pm,tm,0)>=3 Then
imgP1(tm-1).Visible=True
imgP1(tm-1).bitmap=LoadBitmap(File.DirAssets,"a.gif")
Else If arrScores(pm,tm,0)= 2 Then
imgP1(tm-1).Visible=True
imgP1(tm-1).bitmap=LoadBitmap(File.DirAssets,"b.gif")
Else If arrScores(pm,tm,0)= 1 Then
imgP1(tm-1).Visible=True
imgP1(tm-1).bitmap=LoadBitmap(File.DirAssets,"c.gif")
Else If arrScores(pm,tm,0)= 0 Then
imgP1(tm-1).Visible=False
End If
Case 2
If arrScores(pm,tm,0)>=3 Then
imgP2(tm-1).Visible=True
imgP2(tm-1).bitmap=LoadBitmap(File.DirAssets,"a.gif")
Else If arrScores(pm,tm,0)= 2 Then
imgP2(tm-1).Visible=True
imgP2(tm-1).bitmap=LoadBitmap(File.DirAssets,"b.gif")
Else If arrScores(pm,tm,0)= 1 Then
imgP2(tm-1).Visible=True
imgP2(tm-1).bitmap=LoadBitmap(File.DirAssets,"c.gif")
Else If arrScores(pm,tm,0)= 0 Then
imgP2(tm-1).Visible=False
End If
Case 3
If arrScores(pm,tm,0)>=3 Then
imgP3(tm-1).Visible=True
imgP3(tm-1).bitmap=LoadBitmap(File.DirAssets,"a.gif")
Else If arrScores(pm,tm,0)= 2 Then
imgP3(tm-1).Visible=True
imgP3(tm-1).bitmap=LoadBitmap(File.DirAssets,"b.gif")
Else If arrScores(pm,tm,0)= 1 Then
imgP3(tm-1).Visible=True
imgP3(tm-1).bitmap=LoadBitmap(File.DirAssets,"c.gif")
Else If arrScores(pm,tm,0)= 0 Then
imgP3(tm-1).Visible=False
End If
Case 4
If arrScores(pm,tm,0)>=3 Then
imgP4(tm-1).Visible=True
imgP4(tm-1).bitmap=LoadBitmap(File.DirAssets,"a.gif")
Else If arrScores(pm,tm,0)= 2 Then
imgP4(tm-1).Visible=True
imgP4(tm-1).bitmap=LoadBitmap(File.DirAssets,"b.gif")
Else If arrScores(pm,tm,0)= 1 Then
imgP4(tm-1).Visible=True
imgP4(tm-1).bitmap=LoadBitmap(File.DirAssets,"c.gif")
Else If arrScores(pm,tm,0)= 0 Then
imgP4(tm-1).Visible=False
End If
Case Else
Msgbox("Something went really wrong!!!","Ooooops")
End Select
Next
Next
End Sub