Android Question Check for view being initialized but not added, "Layout not available"

JohnK

Active Member
Licensed User
Longtime User
This seemed like such a common occurrence to me, I would of thought it would of been posted many many times before, but I searched and could not find an answer. So, I am really sorry, if it has (as I would of thought).

Normally, I can use code as bellow:
B4X:
Sub MySub
    If RandomView <> Null AND RandomView.IsInitialized Then
       RandomView.BringToFront  
    End If
End Sub
The above will work UNLESS the "RandomView" has been initialized, but not added to a parent view.

Is there anyway to check this state without triggering an error?
 

JohnK

Active Member
Licensed User
Longtime User
Thanks, and sorry, I thought I had tried that already.
=============
Yep. I think I must of. I am running v3.2, and it does not appear to be available in my version. The view I am trying it with is specifically a Panel.
 
Upvote 0

JohnK

Active Member
Licensed User
Longtime User
For future reference for anyone else searching, It works as long as I check as below
B4X:
Dim ParentView As View = Globals.getParent(RandomView)
If ParentView <> Null AND ParentView.IsInitialized Then
  ...
A simple NULL check failed.
 
Upvote 0
Top