Worksheet Template Lab
Worksheet Template Lab
Experiment No:2.2
Aim: Create an Android App using various controls such TexEdit, CheckBox,
RadioButton, RadioGroup, etc.
Objective: The objective of an Android app using various controls such as EditText,
CheckBox, RadioButton, and RadioGroup could be to create a user interface that involves
user input, selection, and interaction with different types of controls. This type of app aims
to showcase the usage and functionalities of these UI elements to enhance the user
experience.
Input/Apparatus Used:
To create an Android app using various controls such as EditText, CheckBox,
RadioButton, and RadioGroup, we need the following tools and resources:
1. Integrated Development Environment (IDE): Android Studio: The official IDE for
Android development. Download and install Android Studio from the official website:
Android Studio.
2. Android SDK: The Android Software Development Kit (SDK) is essential for
developing Android applications. Android Studio usually comes bundled with the SDK,
but you may need to update it through the SDK Manager within Android Studio.
3. Java Development Kit (JDK): Android apps are primarily written in Java or Kotlin.
Make sure you have the Java Development Kit installed. Android Studio supports JDK.
You can download it from the Oracle website: Java SE Downloads.
Procedure:
Step 1: Select Empty Views Activity.
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/silas_baisch_51quglv6en0_unsplash"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="219dp"
android:layout_height="64dp"
android:gravity="center"
android:text="Select the weather"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.086" />
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="299dp"
android:layout_height="202dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.102">
<RadioButton
android:id="@+id/radioButton4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Sunny" />
<RadioButton
android:id="@+id/radioButton6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Rainy" />
<RadioButton
android:id="@+id/radioButton7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
android:textStyle="bold"
android:text="Coldy" />
</RadioGroup>
<TextView
android:id="@+id/textView1"
android:layout_width="219dp"
android:layout_height="64dp"
android:gravity="center"
android:text="What other options You want in Your Day?"
android:textColor="@color/black"
android:textSize="21dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.406"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.649" />
<CheckBox
android:id="@+id/checkBox6"
android:layout_width="298dp"
android:layout_height="52dp"
android:text="Snow"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.762" />
<CheckBox
android:id="@+id/checkBox7"
android:layout_width="294dp"
android:layout_height="51dp"
android:text="Thunder"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.478"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.867" />
<Button
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
android:id="@+id/showDetailsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox7"
app:layout_constraintVertical_bias="0.2" />
</androidx.constraintlayout.widget.ConstraintLayout>
package com.example.toast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
subs = findViewById(R.id.radioGroup);
accessories = findViewById(R.id.checkBox6);
noAccessories = findViewById(R.id.checkBox7);
showDetailsButton = findViewById(R.id.showDetailsButton);
accessories.setOnCheckedChangeListener(checkedChangeListener);
Step 5: Connect your Device and check whether device Is detected by the ADV
and hit run
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Result: On Clicking the Submit Button a TOAST comes up showing the information
Learning Outcomes:
1. Learned about Toast in Android Studio.