2013-10-26 2 views
3

AdMob이 프래그먼트에 표시되지 않습니다. 활동, 코드는 다음과 같습니다. 동일한 코드는 일반적인 활동에서 작동합니다. 이 코드에서 무엇이 잘못되었는지 알지 못합니다. 제안하십시오AdMob이 프래그먼트에 표시되지 않음 작업

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.fragment_delete); 

    adView = (AdView)findViewById(R.id.adView); 
    adView.loadAd(new AdRequest()); 

}

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:focusableInTouchMode="true" 
    android:orientation="vertical" > 

    <Button 
     android:id="@+id/button" 
     style="@style/button_style" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="15dp" 
     android:background="@drawable/button_background" 
     android:text="@string/delete" /> 

    <LinearLayout 
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/advertisement" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <com.google.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      ads:adSize="SMART_BANNER" 
      ads:adUnitId="6693e1e6c1d543f4" > 
     </com.google.ads.AdView> 
    </LinearLayout> 

    <TextView 
     android:id="@+id/textView_startdate" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:singleLine="true" 
     android:text="@string/start_date" /> 

    <EditText 
     android:id="@+id/editText_startdate" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:focusableInTouchMode="false" 
     android:hint="@string/dateFormat" 
     android:inputType="date" /> 

    <requestFocus /> 

    <TextView 
     android:id="@+id/textView_enddate" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/end_date" /> 

    <EditText 
     android:id="@+id/editText_enddate" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:focusableInTouchMode="false" 
     android:hint="@string/dateFormat" 
     android:inputType="date" 
     android:singleLine="true" /> 
</LinearLayout> 

의 AndroidManifest.xml

<uses-sdk 
    android:minSdkVersion="11" 
    android:targetSdkVersion="17" /> 

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<!-- Required permission to check licensing. --> 
<uses-permission android:name="com.android.vending.CHECK_LICENSE" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Holo.Light" > 
    <activity 
     android:name=".MainFragmentActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

     <meta-data 
      android:name="android.app.default_searchable" 
      android:value=".extra.SearchManager" /> 
    </activity> 
    <activity 
     android:name=".DeleteRecords" 
     android:parentActivityName=".MainFragmentActivity" 
     android:screenOrientation="portrait" > 
    </activity> 
    <activity 
     android:name="com.google.ads.AdActivity" 
     android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /> 
</application> 

답변

1

매니페스트 파일 (내부 응용 프로그램)에 다음을 추가해야합니다. 또한 아직 완료하지 않았다면 Eclipse 작업 공간에 Google Play 서비스 라이브러리 프로젝트를 추가하고 참조하십시오.

<meta-data android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version"/> 

Here은 Google의 전체 자습서입니다.

관련 문제