用XML创建MoPubView对象

时间:2016-07-02 03:54:55

标签: android xml tags mopub

在哪里创建(在哪个文件夹中)或在哪里查找XML中的MoPubView对象?我试着把这段代码:

      // Declare an instance variable for your MoPubView.
      private MoPubView moPubView;
       public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.console);
moPubView = (MoPubView) findViewById(R.id.adview);
moPubView.setAdUnitId("9122a91cfac3482cb46607622b93d84d");
moPubView.loadAd();
moPubView.setBannerAdListener(this);
 }

  protected void onDestroy() {
    moPubView.destroy();
     super.onDestroy(); 
     }

我放置此代码的活动在哪里:

{{1}}

谢谢,对不起我的英语很差

1 个答案:

答案 0 :(得分:0)

您将第一个代码块放在res / layout / activity_main.xml下 第二个代码块将您置于MainActivity.java