Following is my code:
// Create the adView
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(cd.getBannerAdmobMediationID());
// Lookup your LinearLayout assuming its been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout) findViewById(R.id.layoutNewsPapers);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
String newsAdYearStr = getSavedPreferences("newsAdYear");
String newsAdGender = getSavedPreferences("newsAdGender");
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
adRequestBuilder.addTestDevice("abcdefghi");
if(newsAdYearStr.trim().length() > 0) adRequestBuilder.setBirthday(new GregorianCalendar(Integer.parseInt(newsAdYearStr), 1, 1).getTime());
if(newsAdGender.equalsIgnoreCase("M")) adRequestBuilder.setGender(AdRequest.GENDER_MALE);
if(newsAdGender.equalsIgnoreCase("F")) adRequestBuilder.setGender(AdRequest.GENDER_FEMALE);
AdRequest adRequest = adRequestBuilder.build();
adView.loadAd(adRequest);
The layout file is as follows:
<LinearLayout android:id="@+id/layoutMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ClrBlack" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="10sp"
android:gravity="center_horizontal"
android:padding="2dp"
android:layout_margin="5dip">
<TextView
android:id="@+id/textInstruct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="@string/selectStateTxt" />
</TableRow>
</TableLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
</LinearLayout>
What is going wrong?
android:layout_width="320dp"
android:layout_height="50dp"