2013-10-24 2 views
0

AdView는 몇 초 후에 표시되지만 투명하며 listView가 전체 화면을 차지합니다. 모든 곳을 보았지만 Adview가 작동하지 않습니다. ListView가 Adview를위한 공간을 만들기 위해 내가 뭘 잘못하고 있는지 알 수 있습니까?ListActivity에서 Admob 투명

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

내가 맨 위에 목록 조각을 마련했다

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="50dp" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="xxxxxxxxxxxxxx" 
     ads:loadAdOnCreate="true" 
     ads:testDevices="TEST_EMULATOR" 
     android:background="@android:color/black" /> 

    <LinearLayout 
     android:id="@+id/home_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/adView" 
     android:orientation="vertical" > 

     <ListView 
      android:id="@id/android:list" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@android:color/black" > 
     </ListView> 

    </LinearLayout> 

</RelativeLayout> 

example of problem

답변

0

activity_with_adview.xml. 조각이 목록이라고 생각했습니다.

@Override 
protected void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 

    this.setContentView(R.layout.activity_with_adview); 

    if (TradiesBillingManager.hasPurchasedDiary()) { 

     if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) { 
      DiaryFragment list = new DiaryFragment(); 
      list.setArguments(getIntent().getExtras()); 
      getSupportFragmentManager().beginTransaction().add(android.R.id.content, list).commit(); 
     } 

    } else { 

     DiaryFragment list = new DiaryFragment(); 
     list.setArguments(getIntent().getExtras()); 
     getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout, list).commit(); 
    } 

} 

당신은 당신이 마지막을 선언 상대 레이아웃과 뷰를 사용하는

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="50dp" 
     android:layout_alignParentTop="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="xxxxxxxxxxxxxx" 
     ads:testDevices="TEST_EMULATOR" 
     ads:loadAdOnCreate="true" 
     android:background="@android:color/black" /> 

    <FrameLayout 
     android:id="@+id/frame_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/adView" 
     android:orientation="vertical" /> 

</RelativeLayout> 
0

activity_with_adview.xml는 다른 뷰의 상단에 그려진됩니다. 목록보기 위에 광고를 추가하려면 xml 파일의 LinearLayout 아래에 AdView 위젯을 선언해야합니다.