예제 #1
0
        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);
        }