moster67 Expert Licensed User Longtime User Nov 26, 2016 #1 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?
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?
Cableguy Expert Licensed User Longtime User Nov 26, 2016 #2 One way is to check if the view has a parent. Upvote 0
moster67 Expert Licensed User Longtime User Nov 26, 2016 #3 Cableguy said: One way is to check if the view has a parent. Click to expand... Can you show a code snippet which does that? Upvote 0
Cableguy said: One way is to check if the view has a parent. Click to expand... Can you show a code snippet which does that?
Cableguy Expert Licensed User Longtime User Nov 26, 2016 #4 I never did, but there are already snippets using reflection about getting views properties that are not accessible through the views directly... Check this thread: https://www.b4x.com/android/forum/threads/puzzling-me.47427/#post-294302 Upvote 0
I never did, but there are already snippets using reflection about getting views properties that are not accessible through the views directly... Check this thread: https://www.b4x.com/android/forum/threads/puzzling-me.47427/#post-294302
KMatle Expert Licensed User Longtime User Nov 26, 2016 #5 Another method: You can add views to a list, too. So if you add a view, add it to the list, too. When you remove it, remove it from the list. Check the list, to check if the view is available. Upvote 0
Another method: You can add views to a list, too. So if you add a view, add it to the list, too. When you remove it, remove it from the list. Check the list, to check if the view is available.
udg Expert Licensed User Longtime User Nov 26, 2016 #6 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: Nov 27, 2016 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
Erel B4X founder Staff member Licensed User Longtime User Nov 27, 2016 #7 You can check: Code: Copy If BannerAd.Parent <> Null Then 'it was added End If Upvote 0
moster67 Expert Licensed User Longtime User Nov 27, 2016 #8 Thank you all for your input. At the end I went with Erel's suggestion. Upvote 0