2017-08-20 44 views
0

出於某種原因,我的橫幅廣告在我的主要活動xml文件中用「提示」突出顯示:XML標籤具有空的主體報告標籤正文。驗證在XML/JSP/JSPX/HTML/XHTML文件類型中起作用。Android Studio AdView XML標籤爲空體?

<com.google.android.gms.ads.AdView 
     android:id="@+id/bannerAd" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="@+id/banner_ad_unit_id"></com.google.android.gms.ads.AdView> 

我從來沒有能夠在我的應用程序中顯示的廣告,甚至測試廣告,但始終保持這個AdView中,以防萬一它決定工作一天。在更新Android Studio之後,這是我第一次看到AdView出現這種情況。

+0

有關上述AdView的更多代碼:https://stackoverflow.com/questions/43289029/android-studio-emulator-not-displaying-test-ads-and-real-devices-not-showing-ad – ml50

回答

0

這只是Android Studio的建議,不是錯誤。

只需更改您的代碼:

<com.google.android.gms.ads.AdView 
     android:id="@+id/bannerAd" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="@+id/banner_ad_unit_id"/> 

您也可以按Alt + Enter鍵(或Option + Enter鍵在MacOS),即可查看建議自動編輯。