2012-01-04 6 views
1

ID는 내 앱에 AdMob 광고를 포함하고 싶지만이를 추가하는 방법은 확실하지 않습니다. 물론목록에 AdMob 광고 포함보기

<ListView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:myapp="http://schemas.android.com/apk/res/com.t3hh4xx0r.romcrawler" 
    android:id="@+id/listView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:drawSelectorOnTop="true" > 

    <com.google.ads.AdView 
    android:id="@+id/ad" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    myapp:backgroundColor="#000000" 
    myapp:primaryTextColor="#FFFFFF" 
    myapp:secondaryTextColor="#CCCCCC" /> 
    </ListView> 

가 발생,

내 주요 활동은 내 main.xml에에 된 setContentView를 호출하지만 내 main.xml에 단 하나의 ListView

<ListView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/listView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:drawSelectorOnTop="true" 
    /> 

레이아웃에 AdView가 추가로 구성 listViews는 자식 레이아웃을 가질 수 없기 때문에 실행시에 강제 종료하십시오.

이 문제를 해결하는 가장 좋은 방법은 무엇입니까? 자바에서 광고보기 만들기? 그렇다면 어떻게 작성할지에 대한 예제 코드를 제공 할 수 있습니까?

미리 감사드립니다.

답변

1

다음과 같이 레이아웃을 만듭니다. 이렇게하면 광고가 하단에 표시됩니다. weightSum을 1로 설정하고 listview의 가중치를 1로 지정하면 광고 작성 후 남은 모든 공간이 사용됩니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:weightSum="1" > 

    <ListView 
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:background="#E4E9F5" 
    android:cacheColorHint="#00000000" /> 

    <com.google.ads.AdView 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:id="@+id/adView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="your_adunitid_here" 
    ads:loadAdOnCreate="true" /> 

</LinearLayout> 
+0

올바른 길로 가고 싶지만 실제로 광고가 표시되지 않습니다. logcat에서 광고 URL은 수신되지만 광고는 수신되지 않습니다. 'I/Ads (1432) : onFailedToReceiveAd (광고 요청은 성공했지만 광고 인벤토리 부족으로 인해 광고가 반환되지 않았습니다.) '원인은 무엇입니까? – r2DoesInc

+0

알았습니다. adUnitId를 작성하고 매니페스트에 인터넷 사용 권한을 포함 시켰습니까? – jagsler

+0

내 장치가 테스트 장치로 설정된 후에도 여전히 동일한 메시지가 수신됩니다. 'AdRequest ar = new AdRequest(); ar.addTestDevice ("4B605421C6EAA120E18B7FA165D2E980"); ' – r2DoesInc