Creating Android GridView programmatically

MainActivity.java

package com.mycompany.myapp;

import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.widget.AdapterView.*;

public class MainActivity extends Activity 
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
		
		LinearLayout myLinear1 = new LinearLayout(MainActivity.this);

		TextView myText1 = new TextView(MainActivity.this);
		myText1.setText("Here is my Grid:");
		myText1.setTextSize(23);
		
		final GridView myGridView = new GridView(MainActivity.this);
		myGridView.setNumColumns(2);

		String[] dataList1 = {
			"Grid item one", 
			"Grid item two",
			"Grid item three",
			"Grid item four"
			};
			
		ArrayAdapter<String> gridviewAdpt = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, dataList1);

		myGridView.setAdapter(gridviewAdpt);

		myLinear1.addView(myText1);
		myLinear1.addView(myGridView);

		setContentView(myLinear1);
	}
}