protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_mrec_programmatic); adStatusTextView = FindViewById <TextView>(Resource.Id.status_label); // Create MRec adView = new AppLovinAdView(AppLovinAdSize.Mrec, this); adView.Id = ViewCompat.GenerateViewId(); var mrecConstraintLayout = FindViewById <ConstraintLayout>(Resource.Id.mrec_programmatic_constraint_layout); var layoutParams = new ConstraintLayout.LayoutParams(AppLovinSdkUtils.DpToPx(this, AppLovinAdSize.Mrec.Width), AppLovinSdkUtils.DpToPx(this, AppLovinAdSize.Mrec.Height)); mrecConstraintLayout.AddView(adView, layoutParams); var set = new ConstraintSet(); set.Clone(mrecConstraintLayout); set.Connect(adView.Id, ConstraintSet.Top, mrecConstraintLayout.Id, ConstraintSet.Top, AppLovinSdkUtils.DpToPx(this, 80)); set.CenterHorizontally(adView.Id, mrecConstraintLayout.Id); set.ApplyTo(mrecConstraintLayout); var loadButton = FindViewById <Button>(Resource.Id.load_button); loadButton.Click += LoadButton_Click; adView.SetAdLoadListener(this); adView.SetAdDisplayListener(this); adView.SetAdClickListener(this); adView.SetAdViewEventListener(this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_banner_programmatic); adStatusTextView = FindViewById <TextView>(Resource.Id.status_label); adView = new AppLovinAdView(AppLovinAdSize.Banner, "YOUR_ZONE_ID", this); adView.Id = ViewCompat.GenerateViewId(); var loadButton = FindViewById <Button>(Resource.Id.load_button); loadButton.Click += LoadButton_Click; adView.SetAdLoadListener(this); adView.SetAdDisplayListener(this); adView.SetAdClickListener(this); adView.SetAdViewEventListener(this); // Add programmatically created banner into our container var bannerProgrammaticContentLayout = FindViewById <ConstraintLayout>(Resource.Id.banner_programmatic_layout); bannerProgrammaticContentLayout.AddView(adView, new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, AppLovinSdkUtils.DpToPx(this, 50))); var constraintSet = new ConstraintSet(); constraintSet.Clone(bannerProgrammaticContentLayout); constraintSet.Connect(adView.Id, ConstraintSet.Bottom, Resource.Id.banner_programmatic_layout, ConstraintSet.Bottom, 0); constraintSet.ApplyTo(bannerProgrammaticContentLayout); // Load an ad! adView.LoadNextAd(); }