<font class="popmake-631">Subscribe</font>Subscribe with Androidlift to get new post on mail.

Android Button Example

In Android, just use “android.widget.Button” class to display a normal button.

Android Button represents a push-button. The android.widget.Button is subclass of TextView class and CompoundButton is the subclass of Button class.

There are different types of buttons in android such as RadioButton, ToggleButton, CompoundButton etc.

In this tutorial, we show you how to display a normal button, add a click listener, when user click on the button, open an URL in your Android’s internet browser.

Create project as Button Example in android Studio.

Open “res => layout => activity_main.xml file”, add a button.

Attach a click listener to the button.

When user click on it, open mobile browser and display URL : http://androidlift.galaxystech.com/

File : MainActivity.java

Add app.gradle as

Add AndroidManifest.xml as

Add res=>layout=>toolbar.xml

Run the application.

1. Result, a normal button.


Click on the button, display URL in browser.


Best luck..!