Creating Android ToggleButton programmatically

MainActivity.java

package com.mycompany.myapp;

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

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

		final ToggleButton myToggle = new ToggleButton(MainActivity.this);
		myToggle.setTextSize(23);
		myToggle.setTextOn("On");
		myToggle.setTextOff("Off");
		
		myLinear.addView(myToggle);

		setContentView(myLinear);
	}
}