Android Question Check if a view has already been added to an Activity

moster67

Expert
Licensed User
Longtime User
I add AdMob's BannerAd view to an activity using:
B4X:
Activity.AddView(BannerAd, 0dip, 100%y - AdMobHeight, 100%x, AdMobHeight)

Later somewhere in my code, I remove it by using:
B4X:
BannerAd.RemoveView

At a certain point, , I want to check its status i.e. if it is loaded (added) or not.

How can I do that?
 

Cableguy

Expert
Licensed User
Longtime User
One way is to check if the view has a parent.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi,
I don't know about AdMob's BannerAd, but if it's a view it should sport a Tag property. So set a special value for it before adding and then check for that value cycling on your activity's views when you need to know if it's part of the group.

udg
 
Last edited:
Upvote 0

moster67

Expert
Licensed User
Longtime User
Thank you all for your input.
At the end I went with Erel's suggestion.
 
Upvote 0
Top