Ok, I implemented the below code and put some logging in the setting of the color for the label view. The looping takes about 1 minute to go through a tabhost with 12 tabs on it, updating the foreground and background colors of the views in each tab.
What I am seeing is a repeat pattern as follows:
Tab #0 View #0
Tab #1 View #0
Tab #1 View #1
Tab #2 View #0
Tab #2 View #1
Tab #2 View #2
Tab #3 View #0
Tab #3 View #1
Tab #3 View #2
Tab #3 View #3
Here is the output in the log file for just 3 tabs (it repeats this pattern for all 12 tabs):
Tab #0 View #0
Text=Welcome screen text here.
Text=Copyright ©2014 xxxx
Text=Welcome screen text here.
Text=Copyright ©2014 xxxx
Tab #1 View #0
Text=Welcome screen text here.
Text=Copyright ©2014 xxxx
Text=Welcome screen text here.
Text=Copyright ©2014 xxxx
Tab #1 View #1
Text=Text on tab 1
Text=More text on tab 1
Text=Text on tab 1
Text=More text on tab 1
Tab #2 View #0
Text=Welcome screen text here.
Text=Copyright ©2014 xxxx
Text=Welcome screen text here.
Text=Copyright ©2014 xxxx
Tab #2 View #1
Text=Text on tab 1
Text=More text on tab 1
Text=Text on tab 1
Text=More text on tab 1
Tab #2 View #2
Text=Text on tab 2
Text=More text on tab 2
Text=Text on tab 2
Text=More text on tab 2
Tab #3 View #0
Text=Welcome screen text here.
Text=Copyright ©2014 xxxx
Text=Welcome screen text here.
Text=Copyright ©2014 xxxx
Tab #3 View #1
Text=Text on tab 1
Text=More text on tab 1
Text=Text on tab 1
Text=More text on tab 1
Tab #3 View #2
Text=Text on tab 2
Text=More text on tab 2
Text=Text on tab 2
Text=More text on tab 2
Tab #3 View #3
Text=Text on tab 3
Text=More text on tab 3
Text=Text on tab 3
Text=More text on tab 3
Here is the code. Can anyone tell me what I'm doing wrong and how to correct this?
Sub SetCustomColors
Dim i As Int
If cColors.IsInitialized=False Then
cColors.Initialize
End If
For i = 0 To TabHost1.TabCount - 1
TabHost1.CurrentTab=i
Dim r As Reflector
r.Target = TabHost1
Dim tabParentPanel As Panel
tabParentPanel = r.RunMethod("getTabContentView")
For x = 0 To tabParentPanel.NumberOfViews - 1
Log("Tab #" & i & " View #" & x)
SetViewColors(tabParentPanel.GetView(x))
Next
Next
End Sub
Sub SetViewColors(v As View)
Select Case True
Case v Is CheckBox
Dim chk As CheckBox
chk = v
chk.Color=cColors.GetBG("CHECKBOX")
chk.TextColor=cColors.GetFG("CHECKBOX")
Case v Is EditText
Dim txt As EditText
txt = v
txt.Color=cColors.GetBG("TEXTBOX")
txt.TextColor=cColors.GetFG("TEXTBOX")
Case v Is RadioButton
Dim rad As RadioButton
rad = v
rad.Color=cColors.GetBG("RADIOBUTTON")
rad.TextColor=cColors.GetFG("RADIOBUTTON")
Case v Is Button
Dim but As Button
but = v
but.Color=cColors.GetBG("BUTTON")
but.TextColor=cColors.GetFG("BUTTON")
Case v Is Spinner
Dim spi As Spinner
spi = v
spi.Color=cColors.GetBG("LISTBOX")
spi.TextColor=cColors.GetFG("LISTBOX")
Case v Is Panel
Dim pnl As Panel
pnl = v
pnl.Color=cColors.GetBG("BACKGROUND")
For Each v1 As View In pnl.GetAllViewsRecursive
SetViewColors(v1)
Next
Case v Is Label
Dim lab As Label
lab = v
Log("Text=" & lab.Text)
If lab.Tag="CAPTION" Then
lab.Color=cColors.GetBG("CAPTION")
lab.TextColor=cColors.GetFG("CAPTION")
Else
lab.Color=cColors.GetBG("LABEL")
lab.TextColor=cColors.GetFG("LABEL")
End If
End Select