Adding a Banner With Java Code Instead of XML

If you would like to add our banner to your layout using Java instead of XML, you are able to.  


This is a basic example of adding our banner with Java code (bottom of the layout, center aligned):



            // Get the Main relative layout of the entire activity
            RelativeLayout mainLayout = (RelativeLayout)findViewById(;   
// Define StartApp Banner
           Banner startAppBanner = new Banner(this);
            RelativeLayout.LayoutParams bannerParameters =
                        new RelativeLayout.LayoutParams(
// Add to main Layout
            mainLayout.addView(startAppBanner, bannerParameters);
Was this article helpful?
10 out of 11 found this helpful