2016-07-02 16 views
0

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

<com.mopub.mobileads.MoPubView 
android:id="@+id/adview" 
android:layout_width="fill_parent" 
android:layout_height="50dp" 
/> 

那里是我的活动把这个代码:

 // 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(); 
    } 

谢谢你,和对不起我的英文不好

回答

0

你把第一块res/layout/activity_main.xml下的代码 第二个代码块将您置于MainActivity.java上