我无法解决这个错误,为我的生活。我已经看过谷歌和周围,没有解决方案的工作。我的广告似乎在Android 1.5和1.6版本上运行良好,但在版本2之上,我收到了该错误。“无法获得第一个布局后的viewWidth”错误
我已将广告放入LinearLayout中,这是滚动视图中的第一个布局。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:background="@drawable/bg_wallpaper"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:id="@+id/drillactivity"
android:layout_width="fill_parent"
android:layout_gravity="bottom"
android:layout_height="340dp">
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="my id goes here"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
我没有在广告中使用我班的任何代码。我更喜欢只通过xml来完成。
loadAdOnCreate是做什么的?在我的情况下,它引起了以下警告:“loadAd在广告已加载时调用,因此中止。” –
loadAdOnCreate将在onCreate中加载广告。因此,您不必在onCreate中单独发送广告请求。 – asish