Android Question Ad Banner Showing Problems

cambopad

Active Member
Licensed User
Longtime User
I am trying to integrate HeyZap Ad SDK into my B4A app using Inline Java. I can successfully show Interstitial ad. However, when it come to showing the Banner, I cannot understand how can I do it in Inline Java. The codes to show the banner ad is:
B4X:
import com.heyzap.sdk.ads.BannerAdView;
private BannerAdView bannerAdView;
@Override
public void onCreate(Bundle savedInstanceState) {
    // ...
    Activity activity = this; // Must be an Activity.
    bannerAdView = new BannerAdView(activity);
    // This must be some view in your layout.
    FrameLayout bannerWrapper = (FrameLayout) findViewById(R.id.banner_wrapper);
    // Add the banner ad view to the wrapper.
    bannerWrapper.addView(bannerAdView);
    // Load the banner ad.
    bannerAdView.load();
}

What I don't understand is here:
B4X:
// This must be some view in your layout.
    FrameLayout bannerWrapper = (FrameLayout) findViewById(R.id.banner_wrapper);

Can anyone help me?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I found the problem with your previous thread. A browser plug-in blocked it because of the "banner" in the url...

The Java code you posted refers to a banner that is added in the XML layout. You can do the same thing and load the XML layout with XmlLayoutBuilder library. You will then get the view with the GetView method.
 
Upvote 0

cambopad

Active Member
Licensed User
Longtime User
Thanks you Erel for your reply! So next time, do I have to avoid the words "banner"?

I follow your instruction to get the view with the GetView method successfully, but then I need to pass that view to the following code:

B4X:
// This must be some view in your layout.
    FrameLayout bannerWrapper = (FrameLayout) findViewById(R.id.banner_wrapper);

How can I do it?
 
Upvote 0

cambopad

Active Member
Licensed User
Longtime User
Now, I can pass the view to the above codes successfully!

Thanks you so much! Inline java and XmlBuilder really solve this problem :)

B4A is amazing <3
 
Upvote 0
Top