2014-04-01 3 views
0

여기 여기에 응용 프로그램은 단지 광고가 표시되지 않습니다 잘 작동 xml 파일응용 프로그램이 작동하지만 광고가 표시되지 않습니까?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 

android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" > 

<com.google.android.gms.ads.AdView android:id="@+id/adView" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        ads:adUnitId="MY_AD_UNIT_ID" 
        ads:adSize="BANNER"/> 


<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/hello_world" /> 

</RelativeLayout> 

에서 내 코드 내 MainActivity.java 코드

package com.example.ads; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.Menu; 

import com.google.android.gms.ads.*; 

public class MainActivity extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    // Look up the AdView as a resource and load a request. 
    AdView adView = (AdView)this.findViewById(R.id.adView); 
    AdRequest adRequest = new AdRequest.Builder().build(); 
    adView.loadAd(adRequest); 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.main, menu); 
    return true; 
} 

} 

입니다. 그것은 봇이 AD_UNIT_ID를 제공했기 때문에 또는 nt가로드 된 높이가 0이 되었기 때문에 adview를 wrap_content becuase로 설정하는 것과 같은 잘못된 것입니다. 이유는 매우 느린 인터넷 연결인가? enter image description here

공백 ad.How의 양쪽에있다가 내가 광고

당신은 광고를 게재 "MY_AD_UNIT_ID"를 제공해야한다
+0

인터넷이 작동하지 않는 경우 문제가 될 수 있습니다. –

+1

adView.setApid ("154050"); 이것은 내 appid 자신의 appid로 대체하고 그것이 일한 희망 :) .. 또한 XML 파일에서 또한이 줄 광고에 귀하의 appid를 설정 : adUnitId = "yourappid". –

+0

그래서 저는 MY_AD_UNIT_ID를 154050으로 대체해야합니다. – user3404195

답변

0

(게시 된 질문 아래의 완전한 설명을 참조) 그냥 XML 파일 것을 복사하여 XML 파일에 붙여 넣습니다 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" > 

<com.google.android.gms.ads.AdView android:id="@+id/adView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    ads:adUnitId="MY_AD_UNIT_ID" 
    ads:adSize="BANNER"/> 


<TextView 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/hello_world" /> 

</RelativeLayout> 

이 시도하고 지금은 일 바란다 :

package com.example.ads; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.Menu; 

import com.google.android.gms.ads.*; 

public class MainActivity extends Activity { 

private static final int BANNER_AD_WIDTH = 320;  

@Override 
protected void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.activity_main); 

// Look up the AdView as a resource and load a request. 
AdView adView = (AdView)this.findViewById(R.id.adView); 
AdRequest adRequest = new AdRequest.Builder().build(); 
adView.loadAd(adRequest); 

int placementWidth = BANNER_AD_WIDTH; 
adView.setWidth(placementWidth); 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
// Inflate the menu; this adds items to the action bar if it is present. 
getMenuInflater().inflate(R.menu.main, menu); 
return true; 
} 

} 
+0

작동하지 않습니다. 이것은 내가 이미 쓴 것입니다. – user3404195

+0

광고는 여전히 크기가 같았습니다. – user3404195

+0

고맙습니다. 고맙습니다. – user3404195

0

으로 그것을 커버 할. 당신에게 log-cat 프로젝트를 확인하십시오. 광고 sdk에서 로그에 메시지가 표시되기 때문에 광고가 표시되지 않습니다. "NO inventory to show ad"

따라서 Ad UNIT ID을 입력하고 문제를 보려면 log cat을 확인하십시오.

감사

관련 문제