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:
Code: Copy
Activity.AddView(BannerAd, 0dip, 100%y - AdMobHeight, 100%x, AdMobHeight)

Later somewhere in my code, I remove it by using:
Code: Copy
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?
 
One way is to check if the view has a parent.
 
Upvote 0
Upvote 0
Upvote 0
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
Thank you all for your input.
At the end I went with Erel's suggestion.
 
Upvote 0
Back
Top