Defining a Class and Inherit in a Subclass

One of the cool aspects of the Java language is the definition of classes and the use of sub-classes where inheritance are passed in between elements.

public class MainActivity extends Activity {

private EditText mNameField;
private Button mStartButton;
protected void onCreate(Bundle savedInstanceState) {

mNameField = (EditText)findViewById(;
mStartButton = (Button) findViewById(;

mStartButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String name = mNameField.getText().toString();
Toast.makeText(MainActivity.this, name, Toast.LENGTH_LONG).show();

Being able to pass data from user inputs and understanding the process of data-pass through is critical in Android development. Android SDK makes it a little easier to set up the code as it is intuitive to the declaration of variables and intent of activities.

Leave a Comment

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s