Android application crashes on launch for LinearLayout view with b
<p>I am new to Android. I am trying to create a LinearLayout view with a AddButton and a List view. I have pasted the code below. But as soon as the application launches, It exits with message saying, "Application has stopped unexpectedly". Any clue where I am wrong?</p>

<p>Purpose:
Create a list view with add button at top. The add button will be static and list view scrollable. The add Button is for adding element to List View.</p>

<pre><code>|__Button_|
|         |
|List View|
|         |

public class SimpleListActivity extends ListActivity {
    /** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        LinearLayout mainLayout;
        mainLayout = new LinearLayout(this);
         mainLayout.setOrientation(LinearLayout.VERTICAL);


        int lHeight= LinearLayout.LayoutParams.FILL_PARENT;
        int lWidth = LinearLayout.LayoutParams.WRAP_CONTENT;
        //------------------------

        Button BtnAdd = new Button(this);
        BtnAdd.setWidth(60);
        BtnAdd.setHeight(60);
        BtnAdd.setFocusable(true);
//        BtnAdd.setId(idBtnNext);
        BtnAdd.setText("Add Hosts");
        mainLayout.addView(BtnAdd, new LinearLayout.LayoutParams(lHeight,lWidth));

        String[] mStrings = new String[]{"Android", "Google", "Eclipse"};
        // Create an ArrayAdapter, that will actually make the Strings above appear in the ListView
        this.setListAdapter(new ArrayAdapter&lt;String&gt;(this, 
                        android.R.layout.simple_list_item_1, mStrings));
        ListView lv = getListView();
        //------------------------

        mainLayout.addView(lv, new LinearLayout.LayoutParams(lHeight,lWidth));

        setContentView(mainLayout);

         lv.setOnItemClickListener(new OnItemClickListener() { ....... 

      }
</code></pre>

<p>}</p>

<p>My Manifest file looks like below.</p>

<pre><code>&lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
        &lt;activity android:name=".SimpleListActivity"
                  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=".Page1"&gt;&lt;/activity&gt;
        &lt;activity android:name=".Page2"&gt;&lt;/activity&gt;
        &lt;activity android:name=".Page3"&gt;&lt;/activity&gt;

    &lt;/application&gt;
</code></pre>
