T tamadon Active Member Licensed User Longtime User May 8, 2012 #1 I have the following sub to toggle views visibility Code: Copy Sub ToggleViewVisibility(Mode As Int, Visible As Boolean) Dim i As Int For i=Activity.NumberOfViews-1 To 0 Step -1 If Activity.GetView(i).Tag = Mode Then Activity.GetView(i).Visible = Visible End If Next End Sub But this line "If Activity.GetView(i).Tag = Mode Then" raises an error LastException java.lang.NullPointerException Click to expand... Not all views have tag as I only set the tag value on views that I want to toggle the visibility. What am I doing wrong? Thanks
I have the following sub to toggle views visibility Code: Copy Sub ToggleViewVisibility(Mode As Int, Visible As Boolean) Dim i As Int For i=Activity.NumberOfViews-1 To 0 Step -1 If Activity.GetView(i).Tag = Mode Then Activity.GetView(i).Visible = Visible End If Next End Sub But this line "If Activity.GetView(i).Tag = Mode Then" raises an error LastException java.lang.NullPointerException Click to expand... Not all views have tag as I only set the tag value on views that I want to toggle the visibility. What am I doing wrong? Thanks
Erel B4X founder Staff member Licensed User Longtime User May 8, 2012 #2 You should change it to: Code: Copy If Activity.GetView(i).Tag <> Null AND Activity.GetView(i).Tag = Mode Then Upvote 0
You should change it to: Code: Copy If Activity.GetView(i).Tag <> Null AND Activity.GetView(i).Tag = Mode Then
T tamadon Active Member Licensed User Longtime User May 8, 2012 #3 Ah.. thank you Erel.. That fixed it! Upvote 0
T tamadon Active Member Licensed User Longtime User May 10, 2012 #4 Encountered another issue, somehow this line Code: Copy If Activity.GetView(i).Tag <> Null AND Activity.GetView(i).Tag = Mode Then Never returns true Upvote 0
Encountered another issue, somehow this line Code: Copy If Activity.GetView(i).Tag <> Null AND Activity.GetView(i).Tag = Mode Then Never returns true
T tamadon Active Member Licensed User Longtime User May 10, 2012 #5 On further checking this line Code: Copy Activity.GetView(i).Tag = Mode Never returns true even though the view tag is equal to the Mode value. Come to think of it, could it be that I am comparing a string Activity.GetView(i).Tag with an Integer? Last edited: May 10, 2012 Upvote 0
On further checking this line Code: Copy Activity.GetView(i).Tag = Mode Never returns true even though the view tag is equal to the Mode value. Come to think of it, could it be that I am comparing a string Activity.GetView(i).Tag with an Integer?
margret Well-Known Member Licensed User Longtime User May 10, 2012 #6 Put this message box right before your if statement and see the values it is finding, see if they match: Code: Copy MsgBox(Activity.GetView(i).Tag, Mode) If Activity.GetView(i).Tag <> Null AND Activity.GetView(i).Tag = Mode Then or try: Code: Copy If Activity.GetView(i).Tag <> Null AND (Activity.GetView(i).Tag + 0) = Mode Then Last edited: May 10, 2012 Upvote 0
Put this message box right before your if statement and see the values it is finding, see if they match: Code: Copy MsgBox(Activity.GetView(i).Tag, Mode) If Activity.GetView(i).Tag <> Null AND Activity.GetView(i).Tag = Mode Then or try: Code: Copy If Activity.GetView(i).Tag <> Null AND (Activity.GetView(i).Tag + 0) = Mode Then
T tamadon Active Member Licensed User Longtime User May 10, 2012 #7 Thanks for the suggestion. Figured out Activity.GetView(i).Tag is a string and I have to set Mode to string too. Upvote 0
Thanks for the suggestion. Figured out Activity.GetView(i).Tag is a string and I have to set Mode to string too.