Я пытался следовать инструкциям Google и создать свой Ab Баннер в main.xmlСоздать AdView в main.xml
Я добавил следующий код ниже в макете
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a14df3a26341a7c"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true"
/>
И в моей деятельности я использую
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());
Но он говорит, что не может решить (R.id.adView)
ЛЮБЫЕ идеи? Я пропустил что-то глупое. У файла main.xml нет ошибок?
Вот полный main.xml ....
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:background="@color/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:padding="20dip"
android:orientation="horizontal" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a14df3a26341a7c"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"
/>
<LinearLayout
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/main_title"
android:layout_marginBottom="2dip"
android:textSize="20sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/web_page"
android:layout_marginBottom="5dip"
/>
<Button
android:id="@+id/continue_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/continue_label"
/>
<Button
android:id="@+id/help_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/help_label"
/>
<Button
android:id="@+id/about_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/about_label"
/>
<Button
android:id="@+id/exit_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/exit_label"
android:layout_marginBottom="2dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/copyright"
/>
</LinearLayout>
</LinearLayout>
Пожалуйста, пост полный XML. Кажется, что некоторые отсутствующие теги (или) неправильное размещение вышеуказанной записи в main.xml – kosa
попробуйте пространство имен «http://schemas.android.com/apk/res/com.google.ads» –