Q: android use programmatic view in xml made view OK I have this layout in XML & and this code,
what I am trying to do is set up the linearLayout inside the (main.xml TableLayout) programmatically while still using the main.xml
so that the ads by inner-active show up on the top in the linear layout.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:baselineAligned="false"
    android:orientation="vertical"
    android:stretchColumns="1" >

    <LinearLayout 
        android:id="@+id/linearLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
    </LinearLayout>

    <Button
        android:id="@+id/start"
        style="@android:style/Widget.Button.Inset"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/start" />

    <Button
        android:id="@+id/help"
        style="@android:style/Widget.Button.Inset"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/help" />

    <Button
        android:id="@+id/options"
        style="@android:style/Widget.Button.Inset"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/options" />

</TableLayout>

and this file Main.java
package com.ice_os.android.ad;

import java.util.Hashtable;

import com.ice_os.android.ad.R;
import com.inneractive.api.ads.InneractiveAd;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class Menu extends Activity {
    LinearLayout linear;
    Hashtable<InneractiveAd.IaOptionalParams, String> metaData = new Hashtable<InneractiveAd.IaOptionalParams, String>();
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

         LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("InneractiveAd"));

            linear.findViewById(R.id.linearLayout);


            // Display banner ad
            if (!InneractiveAd.displayAd(Menu.this,linear , "zeitue_PoundAPoliticianAdversion_Android", InneractiveAd.IaAdType.Banner, 120, Menu.this.metaData))
                noConnectivity();


        Button Start = (Button)findViewById(R.id.start);
        Start.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent StartIntent = new Intent(Menu.this,MainActivity.class);
                startActivity(StartIntent);
                //finish();
            }
        });

        Button Help = (Button)findViewById(R.id.help);
        Help.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent HelpIntent = new Intent(Menu.this,Help.class);
                startActivity(HelpIntent);
            }
        });



        Button Options = (Button)findViewById(R.id.options);
        Options.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent OptionsIntent = new Intent(Menu.this,Options.class);
                startActivity(OptionsIntent);
            }
        });

    }

    public Activity getActivity(){
        return this.getActivity();
    }

     public void noConnectivity() {
            AlertDialog alertDialog = new AlertDialog.Builder(Menu.this).create();
            alertDialog.setTitle("This application is free but requires an internet connection");
            alertDialog.setMessage("Please configure your connectivity settings and re-try");
            alertDialog.setButton("Exit", new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                      onBackPressed();
                } });
            alertDialog.show();
        }

      private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                String message = intent.getStringExtra("message");
            }
        };


    @Override
    protected void onDestroy() {
      // Unregister events since the activity is about to be closed. 
      LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
      super.onDestroy();
    }

}

Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ice_os.android.ad"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="7" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".Menu"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".MainActivity" >
        </activity>
        <activity android:name=".Help" >
        </activity>
        <activity android:name="com.ice_os.android.ad.Options" >
        </activity>
         <activity android:name="com.inneractive.api.ads.InneractiveFullScreenView" >
        </activity>

    </application>

</manifest>


A: OK, here is how I solved this.
main.xml nothing needed
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:baselineAligned="false"
    android:orientation="vertical"
    android:id="@+id/table"
    android:stretchColumns="1" >

    <Button
        android:id="@+id/start"
        style="@android:style/Widget.Button.Inset"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/start" />

    <Button
        android:id="@+id/help"
        style="@android:style/Widget.Button.Inset"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/help" />

    <Button
        android:id="@+id/options"
        style="@android:style/Widget.Button.Inset"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/options" />

</TableLayout>

Menu.java
package com.ice_os.android.ad.pound_a_politician;

import java.util.Hashtable;

import com.ice_os.android.ad.pound_a_politician.R;
import com.inneractive.api.ads.InneractiveAd;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TableLayout;

public class Menu extends Activity {
     Hashtable<InneractiveAd.IaOptionalParams, String> metaData = new Hashtable<InneractiveAd.IaOptionalParams, String>();
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
            final TableLayout lnr = (TableLayout) findViewById(R.id.table);
            LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("InneractiveAd"));
            if (!InneractiveAd.displayAd(Menu.this, lnr, "zeitue_PoundAPoliticianAdversion_Android", InneractiveAd.IaAdType.Banner, 120, Menu.this.metaData))
                noConnectivity();


        Button Start = (Button)findViewById(R.id.start);
        Start.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent StartIntent = new Intent(Menu.this,MainActivity.class);
                startActivity(StartIntent);
            }
        });

        Button Help = (Button)findViewById(R.id.help);
        Help.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent HelpIntent = new Intent(Menu.this,Help.class);
                startActivity(HelpIntent);
            }
        });



        Button Options = (Button)findViewById(R.id.options);
        Options.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent OptionsIntent = new Intent(Menu.this,Options.class);
                startActivity(OptionsIntent);
            }
        });

    }

    public Activity getActivity(){
        return this.getActivity();
    }


    public void noConnectivity() {
        AlertDialog alertDialog = new AlertDialog.Builder(Menu.this).create();
        alertDialog.setTitle("This application is free but requires an internet connection");
        alertDialog.setMessage("Please configure your connectivity settings and re-try");
        alertDialog.setButton("Exit", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                  onBackPressed();
            } });
        alertDialog.show();
    }

    private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {

            @SuppressWarnings("unused")
            String message = intent.getStringExtra("message");
        }
    };

    @Override
    protected void onDestroy() {
      LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
      super.onDestroy();
    }

}

Basically what you do is assign the part of the layout you want to add to, to a equivalent layout data type 
final TableLayout lnr = (TableLayout) findViewById(R.id.table);

then you simply add the content to the layout datatype
        if (!InneractiveAd.displayAd(Menu.this, lnr, "zeitue_PoundAPoliticianAdversion_Android", InneractiveAd.IaAdType.Banner, 120, Menu.this.metaData))

Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ice_os.android.ad.pound_a_politician"
    android:versionCode="4"
    android:versionName="4.0" >

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>

        <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <application
        android:icon="@drawable/dark_icon"
        android:label="@string/app_name" >
        <activity
            android:name=".Splash"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".MainActivity"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation">
        </activity>
        <activity android:name=".Menu">
        </activity>
        <activity android:name=".Help" >
        </activity>
        <activity android:name=".Options" >
        </activity>
         <activity android:name="com.inneractive.api.ads.InneractiveFullScreenView" >
        </activity>
        <activity android:name=".GameOver"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation">
        </activity>

    </application>

</manifest>

in the manifest file make sure the permissions are right for the ad service
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

