Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7005097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:18:31+00:00 2026-05-27T21:18:31+00:00

Id like to include AdMobs ads in my app, but Im not sure how

  • 0

Id like to include AdMobs ads in my app, but Im not sure how to add them.

My main activity calls setContentView on my main.xml, but my main.xml consists of only one ListView

<ListView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/listView"
  android:layout_width="match_parent" 
  android:layout_height="wrap_content"
  android:drawSelectorOnTop="true"
  />

Adding the adview to the layout,

<ListView
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:myapp="http://schemas.android.com/apk/res/com.t3hh4xx0r.romcrawler"
  android:id="@+id/listView"
  android:layout_width="match_parent" 
  android:layout_height="wrap_content"
  android:drawSelectorOnTop="true" >

  <com.google.ads.AdView 
    android:id="@+id/ad"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    myapp:backgroundColor="#000000" 
    myapp:primaryTextColor="#FFFFFF" 
    myapp:secondaryTextColor="#CCCCCC" />
  </ListView>

of course causes a force close on launch, as listViews aren’t allowed to have child layouts.

Whats the best way to get around this? Creating the ad view in java? And if so, could you provide some example code of how I would create it?

Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:18:32+00:00Added an answer on May 27, 2026 at 9:18 pm

    Create a layout like this: This way the ad will show at the bottom. By setting the weightSum to 1 and then saying the weight of the listview is 1 it will take all space that is left after creating the ad.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:weightSum="1" >
    
        <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#E4E9F5"
        android:cacheColorHint="#00000000" />
    
        <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="your_adunitid_here"
        ads:loadAdOnCreate="true" />
    
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I do something like #include<iostream> int main() { int x; return 0; }
I'd like to include a zip file as an attachment to in app email
I am thinking of something like: #include <stdio.h> #include <conio.h> #include <stdlib.h> int main(void)
If I come across something like #include somewhere/myheader.h can I automatically jump to that
Generally we import a tlb file at the starting of the program like #include
I would like to include a feature that lets users of my site sort
I would like to include all my .class from a dependency jar into WAR
I would like to include a Google map in a Flash site I am
I would like to include a different file depending on the version of GCC.
I'd like to include Python scripting in one of my applications, that is written

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.