2012-01-08 1 views
0

Я пытаюсь интегрировать Admob в свой TableLayout. К сожалению, он никогда не отображается на экране. Макет содержит только некоторые текстовые поля сверху, а один вид карты, рекламное окно должно быть размещено внизу. Мой макет XML выглядит следующим образом:Интеграция Admob adview в TableLayout/TableRow

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:stretchColumns="1" 
android:id="@+id/main"> 

<TableRow> 

    <TextView 
     android:id="@+id/txt1" 
     android:gravity="center" 
     android:text="text1" 
     android:textSize="25sp" 
     android:layout_span="3"/> 
</TableRow> 


<TableRow> 
    <TextView 
    android:id="@+id/txt2" 
    android:gravity="center" 
    android:text="txt2" 
    android:textSize="25sp" 
    android:layout_span="3" 
    /> 

</TableRow> 

<TableRow> 

    <TextView 
     android:id="@+id/txt3" 
     android:gravity="left" 
     android:text="txt3" 
     android:textSize="25sp" 
     android:paddingLeft="20sp"/> 

    <TextView 
     android:id="@+id/txt4"    
     android:gravity="right" 
     android:text="txt4" 
     android:textSize="25sp" 
     android:paddingRight="20sp"/> 
</TableRow> 

<TableRow> 
<com.google.android.maps.MapView 
    android:layout_span="2" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mapview" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:apiKey="XXX" 
    android:clickable="true" 
    /> 
</TableRow> 

<TableRow> 

<com.google.ads.AdView android:id="@+id/adView" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        ads:adUnitId="XXX" 
        ads:adSize="BANNER" 
        ads:testDevices="TEST_EMULATOR, XXX" 
        ads:loadAdOnCreate="true" 
        android:layout_span="2" 
        /> 
</TableRow> 
</TableLayout> 

Может кто-нибудь сказать мне, что я должен изменить, чтобы получить AdView правильно показано?

+0

Оберните AdView внутри какой-то макет? Вероятно, относительная компоновка и попробуйте. Вот ссылка ссылки из другой дискуссии SO (я знаю, эта ссылка для TabHost не TableLayout, но концепция такая же) http://stackoverflow.com/questions/3576117/android-tabview-layout-with-admob – kosa

+0

Я уже пробовал как это, но это также не сработало :( – nr1

+0

Вы видите журналы в лог-кате, в которых загружен рекламный канал? Если это так, это в основном с вашими настройками макета, игрой с hieght и шириной и т. д., – kosa

ответ

1

Попробуйте этот путь, поскольку я создаю простое демо для вашего понимания ...!?! Я думаю, что это помогает вам

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/background" 
android:shrinkColumns="*" 
android:stretchColumns="*" > 

<TableRow 
    android:id="@+id/tableRow0" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="0" 
    android:background="@drawable/info_headstriplogo" 
    android:gravity="top" > 

    <ImageButton 
     android:id="@+id/ibGMapLocationBack" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left|bottom" 
     android:layout_margin="5dp" 
     android:layout_span="2" 
     android:background="@null" 
     android:contentDescription="@id/ibGMapLocationBack" 
     android:src="@drawable/back" /> 
</TableRow> 

<TableRow 
    android:id="@+id/tableRow1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" > 

    <com.google.android.maps.MapView 
     android:id="@+id/mapView" 
     android:layout_span="2" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:apiKey="0zzbEqGyRIg8wikQPkcwDvqhM6x0TwcSHozLlZg" 
     android:clickable="true" 
     android:enabled="true" /> 
</TableRow> 

<TableRow 
    android:id="@+id/tableRow10" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="0" 
    android:background="@drawable/footerstrip" 
    android:gravity="bottom" > 
</TableRow>