Toogle views visibility

tamadon

Active Member
Licensed User
Longtime User
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

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
 
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
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:
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
 
Last edited:
Upvote 0
Thanks for the suggestion. Figured out Activity.GetView(i).Tag is a string and I have to set Mode to string too.
 
Upvote 0
Back
Top