2011-02-28 4 views
0

私は無料のアプリに広告を配置するためにAdWhirlを使用しています。私は、広告がMapViewの下でListViewの上に表示されるようにしたい。私が何をしようとしても、広告が底を除いてどこにでも表示されることはありません。現在、listViewはXMLで拡張されていますが、AdWhirlViewはJavaコードで作成する必要があります。 LinearLayoutで垂直方向のaddView(adWhirlView)を呼び出すので、広告は常に下部に表示されます。どのように広告を配置すべきかを定義するにはどうすればよいですか?ここでAndroidのレイアウト、addViewを呼び出す前に要素の順序を指定する方法

は私のXMLです:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
      android:orientation="vertical" 
      android:layout_width="fill_parent"    
      android:layout_height="fill_parent"   
      android:id="@+id/layout_main" 
      > 
      <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="0px" 
       android:layout_weight="1">    


      <com.google.android.maps.MapView 
       .... 

     </RelativeLayout>     


      <ListView 
      android:id="@+id/listView"   
      android:layout_width="fill_parent" 
      android:layout_height="0px" 
      android:layout_weight="1"/> 


</LinearLayout> 

答えて

0

はあなたのリストビューは常にAdWhirl後とあれば来ます。この方法は、次のコード

AdManager.setTestDevices(new String[] { AdManager.TEST_EMULATOR }); 
LinearLayout layout = (LinearLayout) findViewById(R.id.layout_ad); 
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "Key"); 
Display d = this.getWindowManager().getDefaultDisplay(); 
RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(d.getWidth(), 52); 
layout.addView(adWhirlLayout, adWhirlLayoutParams); 
layout.invalidate(); 

使用を使用し、コード

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
     android:orientation="vertical" 
     android:layout_width="fill_parent"    
     android:layout_height="fill_parent"   
     android:id="@+id/layout_main" 
     > 
     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="0px" 
      android:layout_weight="1">    


     <com.google.android.maps.MapView 
      .... 

    </RelativeLayout>     

    <LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:id="@+id/layout_ad" 
    android:layout_height="wrap_content" /> 
     <ListView 
     android:id="@+id/listView"   
     android:layout_width="fill_parent" 
     android:layout_height="0px" 
     android:layout_weight="1"/> 
</LinearLayout> 

の下に試してみて、表示する広告はありません。リストビューは地図の直後に表示されます

+0

完璧!最終的に、私はアンドロイドが欠けていた:layout_height = "wrap_content" –

関連する問題