Home / Android / Banners / Crear banners por código

Banners

Crear banners por código

Utilizar un banner es muy sencillo, tienes que crearlo con tu App Key, configurarlo y solicitar un anuncio.

Ejemplo uso mínimo de banners por código:

    public class MainActivity extends Activity {

ViewGroup bannerContainer;
TappxBanner banner;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bannerContainer = (ViewGroup) findViewById(R.id.banner_container);
Context context = this;
banner = new TappxBanner(context, "**YOUR-APP-KEY**"); //Create the banner
banner.setAdSize(AdSize.SMART_BANNER);
bannerContainer.addView(banner); //add the banner to the view
banner.loadAd(); //request a new ad

}

@Override
protected void onDestroy() {
super.onDestroy();
if (banner != null) banner.destroy();
}
}