Q7

Question 7

Create a radio button group with radio button of all courses in your college and on selecting a particular course, teacher-in-charge of that course should appear at the bottom of the screen.

App Insights:

Used RadioGroup and RadioButton and pretty much added the menu options that way and wrote logic code in MainActivity, also used TextView to display output

Browse Source Code

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"
    tools:context=".MainActivity"
    >

    <TextView
        android:id="@+id/t1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="@string/radio_button_demo" />

    <RadioGroup
        android:id="@+id/rg1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="150dp"
        android:paddingLeft="50dp"
        >

        <RadioButton
            android:id="@+id/rb1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Python Programming" />

        <RadioButton
            android:id="@+id/rb2"
            android:layout_width="229dp"
            android:layout_height="wrap_content"
            android:text="Internet Technologies" />

        <RadioButton
            android:id="@+id/rb3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="DBMS" />

        <RadioButton
            android:id="@+id/rb4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Operating Systems" />

        <RadioButton
            android:id="@+id/rb5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Java Programming" />
    </RadioGroup>

</RelativeLayout>

Output

Studio Screenshot Main Activity (1/12)
App Screenshot Main Activity (2/12)
Studio Screenshot Displaying Toast of Chosen Value (3/12)
App Screenshot Displaying Toast of Chosen Value (4/12)
Studio Screenshot Displaying Toast of Chosen Value (5/12)
App Screenshot Displaying Toast of Chosen Value (6/12)
Studio Screenshot Displaying Toast of Chosen Value (7/12)
App Screenshot Displaying Toast of Chosen Value (8/12)
Studio Screenshot Displaying Toast of Chosen Value (9/12)
App Screenshot Displaying Toast of Chosen Value (10/12)
Studio Screenshot Displaying Toast of Chosen Value (11/12)
App Screenshot Displaying Toast of Chosen Value (12/12)

Last updated