Admob in fragments

后端 未结 2 956
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 09:35

I created an empty project with appcompact and tried to add to it the AdMob block

fragment_main.xml



        
2条回答
  •  余生分开走
    2021-01-06 10:11

    THIS IS THE ANSWER ... you will write root before the findViewById. That's all

        AdView mAdView = (AdView) root.findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
    

提交回复
热议问题