私の人生の間、このエラーを修正することはできません。私はGoogleとその周辺を見てきましたが、解決策はありませんでした。 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