<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Android-app-using-Kotlin%2FC2%2FAdding-Radio-Buttons%2FEnglish-timed</id>
		<title>Android-app-using-Kotlin/C2/Adding-Radio-Buttons/English-timed - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Android-app-using-Kotlin%2FC2%2FAdding-Radio-Buttons%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Android-app-using-Kotlin/C2/Adding-Radio-Buttons/English-timed&amp;action=history"/>
		<updated>2026-05-14T07:06:12Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Android-app-using-Kotlin/C2/Adding-Radio-Buttons/English-timed&amp;diff=54021&amp;oldid=prev</id>
		<title>PoojaMoolya: Created page with &quot; {| border=1 | &lt;center&gt;'''Time'''&lt;/center&gt; | &lt;center&gt;'''Narration'''&lt;/center&gt;  |- |00:01 |Welcome to the''' Spoken Tutorial''' on''' Adding Radio buttons.'''  |- |00:06 |In th...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Android-app-using-Kotlin/C2/Adding-Radio-Buttons/English-timed&amp;diff=54021&amp;oldid=prev"/>
				<updated>2020-10-13T10:46:12Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot; {| border=1 | &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Time&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt; | &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt;  |- |00:01 |Welcome to the&amp;#039;&amp;#039;&amp;#039; Spoken Tutorial&amp;#039;&amp;#039;&amp;#039; on&amp;#039;&amp;#039;&amp;#039; Adding Radio buttons.&amp;#039;&amp;#039;&amp;#039;  |- |00:06 |In th...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
{| border=1&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Time'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Narration'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:01&lt;br /&gt;
|Welcome to the''' Spoken Tutorial''' on''' Adding Radio buttons.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:06&lt;br /&gt;
|In this tutorial we will learn to&lt;br /&gt;
&lt;br /&gt;
Add a '''Radio Group '''and '''Radio buttons''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:13&lt;br /&gt;
| And run the '''Kotlin''' '''App''' to see the output in an '''Android''' phone&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:19&lt;br /&gt;
|To record this tutorial, I am using&lt;br /&gt;
&lt;br /&gt;
'''Ubuntu Linux 16.04''' operating system &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:26&lt;br /&gt;
| '''Android Studio''' version 3.x and  '''Android Phone '''with minimum of '''Android''' OS version '''4.03'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:36&lt;br /&gt;
|To follow this tutorial, you should have basic knowledge&lt;br /&gt;
&lt;br /&gt;
'''Java programming language '''and  '''Android Studio'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:46&lt;br /&gt;
|If not, then go through the relevant tutorials on this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:51&lt;br /&gt;
|In this tutorial, we will add '''Radio buttons '''to create '''Male''' and '''Female''' options.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:59&lt;br /&gt;
|The label '''Gender''' will be created using '''TextView '''tool.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:04&lt;br /&gt;
|Let us open '''Android Studio'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:07&lt;br /&gt;
|We will be using the same '''project RegistrationForm''' which we used earlier.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:13&lt;br /&gt;
|In the left panel we can see the list of recently opened '''projects'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:18&lt;br /&gt;
|Or you can click on '''Open an existing Android Studio Project.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:23&lt;br /&gt;
|And then select the''' RegistrationForm '''project''' '''from the saved location.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:27&lt;br /&gt;
|Select the '''project RegistrationForm '''directly from here.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:32&lt;br /&gt;
|It will take some time to load the '''project'''. Wait until it completes loading.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:38&lt;br /&gt;
|Click on '''activity underscore first dot xml''' file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:43&lt;br /&gt;
|We have already created the '''form''' with few '''tools''' earlier.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:48&lt;br /&gt;
|Now we will add some more '''tools'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:52&lt;br /&gt;
|First, let us remove the top '''constraint''' of the '''Click Here''' button and align properly.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:58&lt;br /&gt;
|Once done, we can add the new '''tools''' .&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:02&lt;br /&gt;
|So, drag '''TextView '''to show the label''' Gender '''and''' '''place it below '''Name EditText.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:10&lt;br /&gt;
|Click on this '''TextView''' and change its '''text attribute''' to '''Gender.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:16&lt;br /&gt;
|Now let us align the '''Gender TextView''' as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:21&lt;br /&gt;
|Next we need add a '''Radio Group''' to group the '''radio buttons.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:26&lt;br /&gt;
|Why we need Radio Group?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:39&lt;br /&gt;
| '''Radio group''' can hold the '''Radio Buttons'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:33&lt;br /&gt;
| When '''radio buttons''' are placed inside a '''Radio Group''', the user can only select one '''button''' at one time.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:41&lt;br /&gt;
| We can have any number of '''Radio Groups''' as per the requirement.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:47&lt;br /&gt;
|In the '''palette search '''box, type '''radio''' and find the '''Radio Group''' from the list.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:53&lt;br /&gt;
|Here it is available under '''Buttons''' option. The option could change in the future due to version change.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:02&lt;br /&gt;
|Now select and drag '''Radio Group '''and place it below the '''Gender TextView.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:08&lt;br /&gt;
|Note that''' Radio Group '''is not assigned with a default unique '''ID'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:14&lt;br /&gt;
|So first, we need to give a unique '''ID. '''&lt;br /&gt;
&lt;br /&gt;
Otherwise, the '''tool''' is not able to attach to other '''tools''' via '''constraints'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:23&lt;br /&gt;
|In the '''Attributes '''window, type''' “genderRadioGroup”''' in '''ID''' field and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:31&lt;br /&gt;
|Position it below the '''Gender''' label by aligning the top and side constraints as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:38&lt;br /&gt;
|Let us now add '''Radio Button''' to the '''Radio group.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:42&lt;br /&gt;
|We will add two '''radio buttons '''for '''Gender'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:46&lt;br /&gt;
|Drag it to the '''Component Tree '''panel and release it on the '''genderRadioGroup.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:52&lt;br /&gt;
|Note that it should come under the hierarchy''' '''of '''genderRadioGroup''' and not under''' ConstraintLayout.'''&lt;br /&gt;
|-&lt;br /&gt;
|03:59&lt;br /&gt;
|Now drag one more '''radio button''' and release it on the first '''radio button''' in the '''Component Tree.'''&lt;br /&gt;
|-&lt;br /&gt;
|04:06&lt;br /&gt;
|Now select the first '''radio button''' in the '''Component''' '''Tree''' and change its '''text attribute''' to “'''Male”.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:15&lt;br /&gt;
|Likewise, change the '''text attribute''' to “'''Female” '''for the second '''radio button'''.&lt;br /&gt;
|-&lt;br /&gt;
|04:21&lt;br /&gt;
|We had removed the top '''constraint''' of '''Click Here button '''earlier'''.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:26&lt;br /&gt;
|Now click on the top '''constraint''' of the '''button'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:30&lt;br /&gt;
|Then drag and attach to the bottom of '''Radio Group''' to place it properly.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:36&lt;br /&gt;
|Lastly, run the '''app''' by clicking on the '''Play '''button and check how it looks on the phone.&lt;br /&gt;
|-&lt;br /&gt;
|04:46&lt;br /&gt;
|Next let us see about how to declare '''variables''' in '''Kotlin'''.&lt;br /&gt;
|-&lt;br /&gt;
|04:51&lt;br /&gt;
|'''var x equal to 5'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:54&lt;br /&gt;
|Here, '''Int data type''' is assigned by default to a '''variable x.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:00&lt;br /&gt;
|'''val x equal to 5'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:03&lt;br /&gt;
|The value '''5''' is a '''constant''' when the '''variable''' is declared using '''‘val’ keyword.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:09&lt;br /&gt;
|'''val xcolon  Int equal to 5'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:12&lt;br /&gt;
|Here, we are declaring a '''constant''' value '''5''' to the''' variable x''' of '''type Int.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:20&lt;br /&gt;
|Otherwise, we can say&lt;br /&gt;
&lt;br /&gt;
'''val x colon Int''' and assign the value in the next line as '''xequal to 5'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:30&lt;br /&gt;
|Switch back to '''Android studio''' interface and click on '''FirstActivity dot kt.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:36&lt;br /&gt;
|Now we will write the code that will decide which radio button is selected.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:42&lt;br /&gt;
|First we will create a new '''variable''' to store the gender information.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:47&lt;br /&gt;
|Type this line of code below the code '''var name equal to empty string'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:54&lt;br /&gt;
|In '''setOnClickListener function''', after the '''Toast method''', write the below code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:00&lt;br /&gt;
|This''' function''' returns the '''id '''of the '''Radio Button''' which is selected from the '''Radio Group'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:06&lt;br /&gt;
|The '''Id '''is stored in the '''variable genderId.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:10&lt;br /&gt;
|This '''function returns  minus 1''' when no '''radio button''' is selected.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:15&lt;br /&gt;
|The '''Radio Button''' value is stored in a '''variable selected underscore gender '''by the '''method findViewById'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:23&lt;br /&gt;
|'''findViewById method '''returns the view of which '''ID''' is passed as '''argument'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:29&lt;br /&gt;
|This line extracts the text of the selected '''radio button''' and stores it in the '''gender variable.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:36&lt;br /&gt;
|Now we have a new data '''gender''', which we can pass onto the '''SecondActivity.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:42&lt;br /&gt;
|Type''' '''this code below the previous '''putExtra() method''' in the '''intent method'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:48&lt;br /&gt;
|This new data can now be accessed inside '''SecondActivity dot kt'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:54&lt;br /&gt;
|Click on '''activity underscore second dot xml. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:59&lt;br /&gt;
|Let us resize the '''TextView''' to add the gender information.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:04&lt;br /&gt;
|Now go to '''SecondActivity.kt '''file'''.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07;08&lt;br /&gt;
|Add a new '''variable''' say '''obtainedGender '''as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:13&lt;br /&gt;
|We need to extract the new data of '''gender''', so we will write the code as below.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:19&lt;br /&gt;
|This will store the gender data from '''FirstActivity''' in '''obtainedGender variable. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:25&lt;br /&gt;
|Edit the code of '''TextView''' to add the gender information like this.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:30&lt;br /&gt;
|The '''radio button''' code is ready to run.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:33&lt;br /&gt;
|Click on the '''Play '''button to run the '''Kotlin app.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:38&lt;br /&gt;
|Launch the '''app''' in the phone.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:41&lt;br /&gt;
|Enter your name and select any one of the gender '''radio buttons.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:47&lt;br /&gt;
|Click on the '''Click Here''' button.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:50&lt;br /&gt;
|A new window opens with the output as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:54&lt;br /&gt;
|With this, we come to the end of this tutorial. Let us summarize.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|08:00&lt;br /&gt;
|In this tutorial we learnt to&lt;br /&gt;
&lt;br /&gt;
Add '''Radio Groups''' and '''Radio Buttons'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|08:06&lt;br /&gt;
| Run the '''Kotlin''' '''app''' to see the output in an '''Android''' phone&lt;br /&gt;
|-&lt;br /&gt;
|08:11&lt;br /&gt;
|As an assignment do the following.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|08:14&lt;br /&gt;
| Add one more '''radio button''' to the '''Radio Group '''and change the '''text attribute''' as “'''Others'''”.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|08:21&lt;br /&gt;
| Run the '''Kotlin app''' to check the output.&lt;br /&gt;
|-&lt;br /&gt;
|08:25&lt;br /&gt;
|The video at the following link summarises the Spoken Tutorial project.&lt;br /&gt;
&lt;br /&gt;
Please download and watch it&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|08:33&lt;br /&gt;
|The''' Spoken Tutorial Project''' Team conducts workshops and gives certificates.&lt;br /&gt;
&lt;br /&gt;
For more details, please write to us.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:43&lt;br /&gt;
| Please post your timed queries in this forum. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:47&lt;br /&gt;
| Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|08:54&lt;br /&gt;
|More information on this mission is available at this link.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:59&lt;br /&gt;
| The '''Android app '''and the script for this tutorial was contributed by Abhishek Shah.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|09:05&lt;br /&gt;
|And this is Nirmala Venkat along with the Spoken Tutorial team from IIT Bombay, signing off. &lt;br /&gt;
&lt;br /&gt;
Thanks for watching.&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>PoojaMoolya</name></author>	</entry>

	</feed>