First Sample - Rajesh-Patel/Android GitHub Wiki

package com.example.myfirstapp;

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button;

public class TestClass extends Activity implements OnClickListener { Button btnFirst;

@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.testclass);
	btnFirst = (Button) findViewById(R.id.button3);

	// btnFirst.setOnClickListener(new OnClickListener() {
	//
	// @Override
	// public void onClick(View v) {
	// // TODO Auto-generated method stub
	// Intent intent = new Intent(TestClass.this, MainActivity.class);
	// startActivity(intent);
	// }
	// });
	btnFirst.setOnClickListener(this);
}

@Override
public void onClick(View v) {
	// TODO Auto-generated method stub

	if (v.getId() == R.id.button3) {
		final Intent intent = new Intent(TestClass.this, MainActivity.class);
		startActivity(intent);
	}

}

}

////////////Screen Design////////////

<Button
    android:id="@+id/button3"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />