Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to put AdMob banner on the bottom of a view
    primarykey
    data
    text
    <p>I'm trying to set an AdMob Banner for my app. In my first Activity I've got a ListView, so I need to put the Banner on the bottom of it. I've searched for something on the internet, and I've found something but, unfortunately, it doesn't work for me.</p> <p>I tried to edit the XML file of the main Activity layout, like this:</p> <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" &gt; &lt;ListView android:id="@+id/main_list" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; &lt;com.google.android.gms.ads android:layout_alignParentBottom="true"&gt; &lt;/com.google.android.gms.ads&gt; &lt;/RelativeLayout&gt; </code></pre> <p>But the LogCat says:</p> <pre><code>&gt; 11-27 01:36:21.783: E/AndroidRuntime(19734): FATAL EXCEPTION: main &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): java.lang.RuntimeException: Unable to start &gt;activity ComponentInfo{com.pipodi.lolservicestatuseuwonly/com.pipodi.lolservicestatuseuwonly.MainActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class com.google.ads.AdView &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.app.ActivityThread.access$600(ActivityThread.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.app.ActivityThread$H.handleMessage(ActivityThread.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.os.Handler.dispatchMessage(Handler.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.os.Looper.loop(Looper.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.app.ActivityThread.main(ActivityThread.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at java.lang.reflect.Method.invokeNative(Native Method) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at java.lang.reflect.Method.invoke(Method.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at dalvik.system.NativeStart.main(Native Method) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class com.google.ads.AdView &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.view.LayoutInflater.rInflate(LayoutInflater.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.view.LayoutInflater.inflate(LayoutInflater.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.view.LayoutInflater.inflate(LayoutInflater.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.view.LayoutInflater.inflate(LayoutInflater.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.app.Activity.setContentView(Activity.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at com.pipodi.lolservicestatuseuwonly.MainActivity.onCreate(MainActivity.java:43) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.app.Activity.performCreate(Activity.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): ... 12 more &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ads.AdView" on path: /data/app/com.pipodi.lolservicestatuseuwonly-1.apk &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at java.lang.ClassLoader.loadClass(ClassLoader.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at java.lang.ClassLoader.loadClass(ClassLoader.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): at android.view.LayoutInflater.createView(LayoutInflater.java) &gt;11-27 01:36:21.783: E/AndroidRuntime(19734): ... 22 more </code></pre> <p>This is the method OnCreate:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); // Create the adView. adView = new AdView(this); adView.setAdUnitId("ca-app-pub-9509002681827594/8300786666"); adView.setAdSize(AdSize.BANNER); LinearLayout layout = (LinearLayout)findViewById(R.id.main); // Add the adView to it. layout.addView(adView); // Initiate a generic request. AdRequest adRequest = new AdRequest.Builder().build(); // Load the adView with the ad request. adView.loadAd(adRequest); super.onCreate(savedInstanceState); c=this.getApplicationContext(); list = (ListView)this.findViewById(R.id.main_list); ParsingPaginaWeb parsing = new ParsingPaginaWeb(); parsing.execute(""); } </code></pre> <p>And the last, the Manifest:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.pipodi.lolservicestatuseuwonly" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt; &lt;application android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/&gt; &lt;activity android:name="com.pipodi.lolservicestatuseuwonly.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name="com.pipodi.lolservicestatuseuwonly.PostCatcher" android:label="@string/title_activity_post_catcher" android:parentActivityName="com.pipodi.lolservicestatuseuwonly.MainActivity"&gt; &lt;/activity&gt; &lt;activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>If I edit the XML, putting all the stuff under a single LinearLayout it works, but the Ad is on top, messing up with the tab under it. How can I solve it?</p> <p>Thanks guys!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload