Introduction
In this article, I will explain how to create RadioGroup And RadioButton apps in Android applications using Android Studio.
Requirements
- Android Studio2.1.3
If you want to create RadioGroup and RadioButton, you should follow the given steps.
Step 1
Now, open Android Studio and you can choose File >> New. Afterwards, choose New Project.

Step 2
Here, you can create your application name and choose where your project is stored on the location. Click the NEXT button.

Now, select Target Android devices.

Step 3
Here, we can add the activity, more activity available, and click Next button.

Now, we can write the activity name and click "Finish" button.

Step 4
Now, open your project and go to activity_main.xml and afterwards, build the design. You should choose toolbox and if you want some option (RadioGroup, RadioButton, button), use the drag and drop method.

Now, we can see the Graphical User Interface design.

Step 5
Now, go to the resource folder and select the String.xml. Then, you will add the string value.

srings.xml code
- <resources>
- <string name="app_name">RadioButtonApp</string>
- <string name="CPLUSPLUS">C++</string>
- <string name="JAVA">JAVA</string>
- <string name="CSHARP">C-SHARP</string>
- <string name="ASPNET">ASP.NET</string>
- <string name="ANDROID">ANDROID</string>
- </resources>
Here, you need to build on the design and write the XML code.
activity_main.xml code.
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="xyz.rvconstructions.www.radiobuttonapp.MainActivity">
- <RadioGroup android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentRight="true" android:layout_alignParentEnd="true">
- <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="C++" android:id="@+id/radioButton" android:layout_marginLeft="20dp" android:layout_marginTop="10dp" android:textColor="#154" android:textSize="20sp" android:textStyle="bold" android:layout_gravity="center_horizontal" />
- <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="JAVA" android:id="@+id/radioButton2" android:layout_marginLeft="20dp" android:layout_marginTop="10dp" android:textColor="#1a5511" android:textSize="20sp" android:textStyle="bold" android:layout_gravity="center_horizontal" />
- <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="C-SHARP" android:id="@+id/radioButton3" android:layout_marginLeft="20dp" android:layout_marginTop="10dp" android:textColor="#552711" android:textSize="20sp" android:textStyle="bold" android:layout_gravity="center_horizontal" />
- <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ASP.NET" android:id="@+id/radioButton4" android:layout_marginLeft="20dp" android:layout_marginTop="10dp" android:textColor="#112b55" android:textSize="20sp" android:textStyle="bold" android:layout_gravity="center_horizontal" />
- <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ANDROID" android:id="@+id/radioButton5" android:layout_marginLeft="20dp" android:layout_marginTop="10dp" android:textColor="#205511" android:textSize="20sp" android:textStyle="bold" android:layout_gravity="center_horizontal" />
- <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="submit" android:id="@+id/button" android:layout_margin="20dp" android:background="#fbff00" android:padding="10dp" android:layout_gravity="center_horizontal" />
- </RadioGroup>
- </RelativeLayout> // This is just a sample script. Paste your real code (javascript or HTML) here. if ('this_is'==/an_example/){of_beautifier();}else{var a=b?(c%d):e[f];}








Join the conversation! Your thoughts help the community grow.