A Radio button is used to select a option out of available options. Generally, we see these radio buttons in reservation forms and several other forms.

Now we will see a radio button for selecting a class out of first class, second class, third class. And then click on button to get selected output as toast.

In this tutorial i will show a radio-button using which user can select a class i.e., only one button can be selected at a time, if we select second time first button will be disabled automatically.

Here i am giving the selected value of the radio button stored in a string & toast is given as output.

 

 

 

MainActivity.java

 

 

In layout add radio-group under which radio buttons are added and according to your requirement take radio buttons and also a normal button to submit the value.

 

activity_main.xml

AndroidManifest.xml

Output :

radio-button1

 

radio-button2

Show Buttons
Hide Buttons
Read previous post:
Android Tutorial on Dialog-Box

Close