0% found this document useful (0 votes)
29 views

Madexp 3.1

The document describes an Android application created using fragments. It includes the XML and Java code used to build the application interface with various UI elements like text views, images, checkboxes. It also includes a method to handle checkbox selections and display a toast message. The objective is to create a modular, flexible and scalable user interface using fragments.

Uploaded by

Akhilesh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Madexp 3.1

The document describes an Android application created using fragments. It includes the XML and Java code used to build the application interface with various UI elements like text views, images, checkboxes. It also includes a method to handle checkbox selections and display a toast message. The objective is to create a modular, flexible and scalable user interface using fragments.

Uploaded by

Akhilesh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment – 3.1

Student Name:Akhilesh Singh UID: 21BCS3604


Branch: BE-CSE-IT Section/Group: 644-B
Semester: 6th Date of Performance: 11/03/2024
Subject Name: MAD Lab Subject Code: 21CSH-355

Aim of the practical: Create an Android application using Fragments


Objective:- The objective of an Android application using Fragments can be to enhance the
user interface and improve the overall user experience by leveraging the benefits of fragment-
based design. Fragments allow developers to create more modular, flexible, and scalable UI
components.

1. CODE:
XML:-
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="166dp"
android:layout_height="98dp"
android:text="HELLO World I am Shashi "

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.617" />
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

<EditText
android:id="@+id/editTextExample"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter text"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="67dp" />
<ImageView
android:id="@+id/imageViewExample"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher_foreground" />
<CheckBox
android:id="@+id/checkBoxExample"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Check me" />
<Spinner
android:id="@+id/spinnerExample"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<ProgressBar
android:id="@+id/progressBarExample"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="50" />

<Switch
android:id="@+id/switchExample2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Switch me" />
<ToggleButton
android:id="@+id/toggleButtonExample"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOn="ON"
android:textOff="OFF" />
<AutoCompleteTextView
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

android:id="@+id/autoCompleteTextViewExample"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Type here" />

</androidx.constraintlayout.widget.ConstraintLayout>

Java Code:-

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
CheckBox ch, ch1, ch2, ch3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ch=(CheckBox)findViewById(R.id.checkBox);

ch1=(CheckBox)findViewById(R.id.checkBox2);

ch2=(CheckBox)findViewById(R.id.checkBox3);

ch3=(CheckBox)findViewById(R.id.checkBox4);

}
public void Check(View v)

String msg="";

if(ch.isChecked())

msg = msg + " Painting ";

if(ch1.isChecked())

msg = msg + " Reading ";

if(ch2.isChecked())
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

msg = msg + " Singing ";

if(ch3.isChecked())

msg = msg + " Cooking ";

Toast.makeText(this, msg + "are selected",

Toast.LENGTH_LONG).show();

2. OUTPUT:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

3. Learning Outcomes:
 Successful USE of your Android development environment.
 Project Workspace.
 Configuration button Completion.
 How to add new fregemts.

You might also like