2011-09-06 46 views
0

我有具有以下下面鍵盤打開時AdMob廣告自敗:■


[EDITE TEXT] [BUTTON]

[ADVERT概念格式的edite文本和一個按鈕, 活動]


我的問題是,當我的鍵盤在橫向視圖(軟鍵盤)觸摸編輯文本輸入明顯的東西,廣告自敗後打開。 鍵盤似乎與廣告(視覺上)聯繫在一起,出於某種原因,它刪除了廣告,並將活動推向高級(除了移除廣告之外,正常情況下)。

任何想法如何我可以解決這個問題,或者我可以檢測到當鍵盤關閉時廣告可以重新加載?

+0

您可以檢查使用此示例顯示的鍵盤是否顯示http://stackoverflow.com/questions/2150078/android-is-software-keyboard-shown –

回答

1

在AndroidManifest.xml添加到您的活動聲明:

android:configChanges="orientation|keyboardHidden" 

並添加到您的活動類:

public void onConfigurationChanged(Configuration newConfig) 
{ 
    super.onConfigurationChanged(newConfig); 
} 
3

你應該把你的AdView作爲的RootView的直接子佈局。

<LinearLayout 
    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"> 
<LinearLayout/><!-- Your Layout--></LinearLayout> 
<com.google.ads.AdView 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:id="@+id/adView" 
    ads:adSize="BANNER" 
    ads:loadAdOnCreate="true"/> 

</LinearLayout>