Buttons are Android widget used as a push button.The android.widget.Button is a subclass of TextView class and CompoundButton is the subclass of Button class.

Here in this Android Button Tutorial, we are going to learn handling click event of a button in Android Studio.

Android Button Example

Android Button Example

Step 1: Open up Android Studio Create a Project by clicking File->New->New Project and name it.Here in the tutorial, I am naming Example Button Project.

Step 2: Drag and drop Button from widget section or use this code below for button.

 

Step 3: Create OnClickListener for the button as shown below.OnClickListener handles click events of the button.