Android Development Starter Guide using Android Studio
Creating a Functional Button


Step 1:
After starting a blank activity, create a button for your Main Activity using the design layout.  You can drag the button in.



Step 2:
Add in the onClick method into your button under properties.  Lets call it displayMessage.



Step 3:
Add in the method call displayMessage for your button call in your Main Activity java file.  This method will take in a View object.  Make sure to import classes needed.

//In MainActivity.java
public void displayMessage(View view){

//The following code will create a pop-up message.
Context context = getApplicationContext();
CharSequence text = "Button Clicked!";

Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
toast.show();
}


Step 4:
Now when you click the button, you should see a pop-up message.