2014-11-27 2 views
0

Android (Eclipse)에서 AdView를로드하려면 어떻게해야합니까? 나는 결과없이 모든 것을 시도했다! 프로젝트에서 google play services lib를 추가하면 일부 수동, 문서를 따르려고하지만 아무 것도 광고를 표시하지 않습니다. 이것은 내 코드입니다! 감사Admob Android Eclipse로 AdView로드

SecretsActivity.java

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.carle.segretihs" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="21" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 



    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".HomeActivity" 
     android:label="@string/title_activity_home" 
     android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" > 
    </activity> 


    <activity 
     android:name=".SecretsActivity" 
     android:label="@string/title_activity_secrets" 
     android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" > 
    </activity> 
    <meta-data 
     android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version" /> 

    <activity 
     android:name="com.google.android.gms.ads.AdActivity" 
      android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /> 
</application> 

</manifest> 

매니페스트

public class SecretsActivity extends FragmentActivity { 
ImageView a,b,c,d,e,f,g,h,i,l; 
private InterstitialAd interstitial; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.activity_secrets); 


    int eroe=getIntent().getExtras().getInt("eroe"); 

    a=(ImageView)findViewById(R.id.imageView1); 
    b=(ImageView)findViewById(R.id.imageView2); 
    c=(ImageView)findViewById(R.id.imageView3); 
    d=(ImageView)findViewById(R.id.imageView4); 
    e=(ImageView)findViewById(R.id.imageView5); 
    f=(ImageView)findViewById(R.id.imageView6); 
    g=(ImageView)findViewById(R.id.imageView7); 
    h=(ImageView)findViewById(R.id.imageView8); 
    i=(ImageView)findViewById(R.id.imageView9); 
    l=(ImageView)findViewById(R.id.imageView10); 

    AdView adView = (AdView)this.findViewById(R.id.adView); 
    AdRequest adRequest = new AdRequest.Builder() 
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
    .addTestDevice("TEST_DEVICE_ID") 
    .build(); 
    adView.loadAd(adRequest); 

    //other code 


} 
} 

activity_secrets.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/hearthtexture" 
tools:context="${relativePackage}.${activityClass}" 
android:id="@+id/rootViewGroup" 
> 

<com.google.android.gms.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="ca-app-pub-2830551115211229/5191182799" > 
</com.google.android.gms.ads.AdView> 

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/adView" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center" 
     android:orientation="vertical" > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" /> 

     <ImageView 
      android:id="@+id/imageView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" /> 

     <ImageView 
      android:id="@+id/imageView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" /> 

     <ImageView 
      android:id="@+id/imageView4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" /> 

     <ImageView 
      android:id="@+id/imageView5" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" /> 

     <ImageView 
      android:id="@+id/imageView6" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" /> 

     <ImageView 
      android:id="@+id/imageView7" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" /> 

     <ImageView 
      android:id="@+id/imageView8" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <ImageView 
      android:id="@+id/imageView9" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <ImageView 
      android:id="@+id/imageView10" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 
</ScrollView> 

</RelativeLayout> 
+1

실제로 광고 요청을 수행하는 코드를 표시합니다. pls – Michael

+0

그것은 "// 다른 코드"앞에 있습니다 – Carle

+0

광고와 관련된 logcat에서 무엇을 볼 수 있습니까? – Kunalxigxag

답변

0

있는 ScrollView 아래 com.google.android.gms.ads.AdView 퍼팅 시도 XML로. 스크롤보기가 화면보다 크면 광고보기가 그 아래에 숨겨집니다.

+0

AdView의 요청을로드하기위한 지침을 삽입하면 앱이 다운됩니다. 레이아웃 문제가 아닙니다. – Carle