0% found this document useful (0 votes)
18 views86 pages

Android Record

This document is a practical record notebook for a Mobile App Development lab course at Virudhunagar Hindu Nadars’ Senthikumara Nadar College, detailing exercises completed by student Anbu Selvan P. It includes a bonafide certificate, an index of practical exercises, and coding examples for various mobile app projects. The exercises cover topics such as layout design, user interface elements, and database operations, all aimed at enhancing practical skills in mobile app development.

Uploaded by

anbuselvan0396
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)
18 views86 pages

Android Record

This document is a practical record notebook for a Mobile App Development lab course at Virudhunagar Hindu Nadars’ Senthikumara Nadar College, detailing exercises completed by student Anbu Selvan P. It includes a bonafide certificate, an index of practical exercises, and coding examples for various mobile app projects. The exercises cover topics such as layout design, user interface elements, and database operations, all aimed at enhancing practical skills in mobile app development.

Uploaded by

anbuselvan0396
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/ 86

Virudhunagar Hindu Nadars’ SenthikumaraNadar

College
(An Autonomous Institution, Affiliated to Madurai Kamaraj University)
(Accredited with ‘A+’ Grade by NAAC)
Low Cost Access to High Quality Education
Virudhunagar – 626 001

Department of Computer Science

Practical Record Notebook

LAB: Mobile APP Development (U24CSCP61)

NAME : ANBU SELVAN P

REG.NO : 22AUCS018

APRIL - 2025
Virudhunagar Hindu Nadars’Senthikumara Nadar
College
(An Autonomous Institution, Affiliated to Madurai Kamaraj University)
(Accredited with ‘A+’ Grade by NAAC)
Low Cost Access to High Quality Education
Virudhunagar – 626 001
BONAFIDE CERTIFICATE

Department of Computer Science

This is to certify that this is the Bonafide record of work done by,
NAME : ANBU SELVAN P
REG.NO : 22AUCS018
Studying III Year in B.Sc. Computer Science, submitted for
the summative practical examinations APRIL 2025
LAB: Mobile APP Development (U24CSCP61)
held on 01/04/ 2025.

Staff In-charge Head of the


Department
Internal Examiner External Examiner
INDEX

S.No Date Exercise Page


no.
1. 06.12.2024 Rainbow coloring using linear layout
2. 12.12.2024 Resume preparation using relative
layout
3. 16.12.2024 Day order schedule using table layout
4. 20.12.2024 Display Phone details using grid
layout
5. 24.12.2024 Registration form designing using
absolute layout
6. 03.01.2025 Website creation using frame layout
7. 03.01.2025 Displaying date using date picker
8. 09.01.2025 Login form checking
9. 21.01.2025 Calculator designing using Button
10. 21.01.2025 Program to demonstrate static intent
11. 18.02.2025 Program to demonstrate dynamic
intent
12. 18.02.2025 Program to Prepare quiz using Radio
Button
13. 26.02.2025 Program to Perform string operations
14. 04.03.2025 Program to create age calculator using
date picker
15. 04.03.2025 Program to create bill calculation
using checkbox
16. 12.03.2025 Program to create menu options
17. 12.03.2025 Program to perform array operations
18. 12.03.2025 Program to insert and retrieve student
details using database
19. 12.03.2025 Program to perform electricity bill
calculations using database.

Program 1: Rainbow coloring using linear layout

Coding:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/rainbow"
android:layout_marginLeft="150dp" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/violet"
android:textSize="30dp"
android:gravity="center"
android:background="#5F2879"
android:textColor="#000000"/>
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/indigo"
android:textSize="30dp"
android:gravity="center"
android:background="#00418D"
android:textColor="#000000"/>
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/blue"
android:textSize="30dp"
android:gravity="center"
android:background="#00C2DE"
android:textColor="#000000"/>
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/green"
android:textSize="30dp"
android:gravity="center"
android:background="#00BA71"
android:textColor="#000000"/>
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/yellow"
android:textSize="30dp"
android:gravity="center"
android:background="#FAD717"
android:textColor="#000000"/>
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/orange"
android:textSize="30dp"
android:gravity="center"
android:background="#FA8901"
android:textColor="#000000"/>
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/red"
android:textSize="30dp"
android:gravity="center"
android:background="#FF3545"
android:textColor="#000000"/>
</LinearLayout>

Output:
Program 2: Resume preparation using relative layout

Coding:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#CAC4C4"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FAD717"
android:orientation="vertical">
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="180px"
android:text="Resume"
android:textSize="35dp"
android:textColor="#00BA71" />
<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="90dp"
android:text="Name"
android:textColor="#00418D" />
<TextView
android:id="@+id/textview3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="90dp"
android:text="ANBU SELVAN P"
android:textColor="#000000" />
<TextView
android:id="@+id/textview4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="130dp"
android:text="DOB"
android:textColor="#00418D" />
<TextView
android:id="@+id/textview5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="130dp"
android:text="27/12/2004"
android:textColor="#000000" />
<TextView
android:id="@+id/textview6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="170dp"
android:text="Age"
android:textColor="#00418D" />
<TextView
android:id="@+id/textview7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="170dp"
android:text="20"
android:textColor="#000000" />
<TextView
android:id="@+id/textview8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="210dp"
android:text="Gender"
android:textColor="#00418D" />
<TextView
android:id="@+id/textview9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="210dp"
android:text="Male"
android:textColor="#000000" />
<TextView
android:id="@+id/textview10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="250dp"
android:text="Qualification"
android:textColor="#00418D" />
<TextView
android:id="@+id/textview11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="250dp"
android:text="Bsc Computer Science"
android:textColor="#000000" />
<TextView
android:id="@+id/textview12"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="290dp"
android:text="Technical Skills"
android:textColor="#00418D" />
<TextView
android:id="@+id/textview13"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="290dp"
android:text="C,Python,Java,Php"
android:textColor="#000000" />
<TextView
android:id="@+id/textview14"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="330dp"
android:text="Phone Number"
android:textColor="#00418D" />
<TextView
android:id="@+id/textview15"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="330dp"
android:text="8778908158"
android:textColor="#000000" />
<TextView
android:id="@+id/textview16"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="370dp"
android:text="Email ID"
android:textColor="#00418D" />
<TextView
android:id="@+id/textview17"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="370dp"
android:text="[email protected]"
android:textColor="#000000" />
<TextView
android:id="@+id/textview18"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="410dp"
android:text="Address"
android:textColor="#00418D" />
<TextView
android:id="@+id/textview19"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="410dp"
android:text="139,58,Smg school street,Virudhunagar"
android:textColor="#000000" />
</RelativeLayout>
</ScrollView>

Output:
Program 3:Day order schedule using table layout
Coding:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF" >
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:textSize="10px">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Time"
android:textSize="18px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="9:30 to 10:30"
android:textSize="15px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="10:30 to 11:30"
android:textSize="15px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="11:30 to 12:30"
android:textSize="15px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="1:30 to 2:30"
android:textSize="15px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="2:30 to 3:30"
android:textSize="15px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:textSize="10px">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="1"
android:textSize="18px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Android Lab"
android:layout_span="3"
android:gravity="center"
android:textSize="15px"
android:textColor="#000000"
android:background="#FAD717"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Project"
android:textSize="13px"
android:background="#00BA71"
android:textColor="#000000"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="SE"
android:textSize="13px"
android:textColor="#000000"
android:background="#00C2DE"
android:paddingRight="10px" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:textSize="10px">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="2"
android:textSize="18px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="DC"
android:textSize="13px"
android:textColor="#FFFFFF"
android:background="#5F2879"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="RP"
android:textSize="13px"
android:textColor="#000000"
android:background="#FA8901"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Projrct"
android:textSize="13px"
android:textColor="#000000"
android:background="#00BA71"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Project(DC)"
android:layout_span="2"
android:gravity="center"
android:textSize="15px"
android:textColor="#000000"
android:background="#00BA71"
android:paddingRight="10px" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:textSize="10px">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="3"
android:textSize="18px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Android Lab"
android:layout_span="3"
android:gravity="center"
android:textSize="15px"
android:textColor="#000000"
android:background="#FAD717"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="NME"
android:textSize="13px"
android:textColor="#000000"
android:background="#BAC51A"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="RP"
android:textSize="13px"
android:textColor="#000000"
android:background="#FA8901"
android:paddingRight="10px" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:textSize="10px">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="4"
android:textSize="18px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="RP"
android:textSize="13px"
android:textColor="#000000"
android:background="#FA8901"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="SE"
android:textSize="13px"
android:textColor="#000000"
android:background="#00C2DE"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="DC"
android:textSize="13px"
android:textColor="#FFFFFF"
android:background="#5F2879"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=".NET Lab"
android:layout_span="2"
android:gravity="center"
android:textSize="15px"
android:textColor="#000000"
android:background="#5AE2E0"
android:paddingRight="10px" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:textSize="10px">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="5"
android:textSize="18px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="NODEJS Lab"
android:layout_span="2"
android:gravity="center"
android:textSize="15px"
android:textColor="#000000"
android:background="#E96CA4"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="DC"
android:textSize="13px"
android:textColor="#FFFFFF"
android:background="#5F2879"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="NME"
android:textSize="13px"
android:textColor="#000000"
android:background="#BAC51A"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TK"
android:textSize="13px"
android:textColor="#000000"
android:background="#EFC3CA"
android:paddingRight="10px" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:textSize="10px">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="6"
android:textSize="18px"
android:textColor="#000000"
android:background="#FFFFFF"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="DC"
android:textSize="13px"
android:textColor="#FFFFFF"
android:background="#5F2879"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="RP"
android:textSize="13px"
android:textColor="#000000"
android:background="#FA8901"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TK"
android:textSize="13px"
android:textColor="#000000"
android:background="#EFC3CA"
android:paddingRight="10px" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Project(DC)"
android:layout_span="2"
android:gravity="center"
android:textSize="15px"
android:textColor="#000000"
android:background="#00BA71"
android:paddingRight="10px" />
</TableRow>
</TableLayout>

Output:
Program 4: Display Phone details using grid layout
Coding:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="50"
android:orientation="vertical"
android:padding="16dp"
android:rowCount="39" >
<ImageView
android:layout_width="89dp"
android:layout_height="160dp"
android:layout_column="0"
android:layout_gravity="right"
android:layout_row="0"
android:layout_rowSpan="4"
android:src="@drawable/mobile2" />
<ImageView
android:layout_width="108dp"
android:layout_height="156dp"
android:layout_column="0"
android:layout_gravity="bottom|right"
android:layout_row="5"
android:layout_rowSpan="5"
android:src="@drawable/mobile1" />
<ImageView
android:layout_width="108dp"
android:layout_height="156dp"
android:layout_column="0"
android:layout_gravity="right"
android:layout_row="10"
android:layout_rowSpan="8"
android:src="@drawable/mobile" />
<TextView
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_columnSpan="4"
android:layout_row="12"
android:paddingRight="10dp"
android:text="iphone 15Max"
android:textColor="#FFFFFF"
android:textSize="18dp" />
<TextView
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_column="3"
android:layout_columnSpan="3"
android:layout_gravity="bottom"
android:layout_row="0"
android:paddingRight="10px"
android:text="iphone 16Max"
android:textColor="#FFFFFF"
android:textSize="18dp" />
<TextView
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_column="3"
android:layout_columnSpan="3"
android:layout_row="7"
android:paddingRight="10dp"
android:text="iphone 16Max"
android:textColor="#FFFFFF"
android:textSize="18dp" />
<TextView
android:layout_width="330dp"
android:layout_height="wrap_content"
android:layout_column="4"
android:layout_columnSpan="2"
android:layout_row="14"
android:paddingRight="10dp"
android:text="Red"
android:textColor="#FFFFFF"
android:textSize="18dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_column="4"
android:layout_columnSpan="2"
android:layout_gravity="bottom"
android:layout_row="17"
android:paddingRight="10dp"
android:text="$70000"
android:textColor="#FFFFFF"
android:textSize="18dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_column="5"
android:layout_gravity="bottom"
android:layout_row="1"
android:paddingRight="10dp"
android:text="$90000"
android:textColor="#FFFFFF"
android:textSize="18dp" />
<TextView
android:layout_width="330dp"
android:layout_height="wrap_content"
android:layout_column="5"
android:layout_row="2"
android:paddingRight="10dp"
android:text="Pink"
android:textColor="#FFFFFF"
android:textSize="18dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_column="5"
android:layout_row="8"
android:paddingRight="10dp"
android:text="$70000"
android:textColor="#FFFFFF"
android:textSize="18dp" />
<Space
android:layout_width="25dp"
android:layout_height="1dp"
android:layout_column="1"
android:layout_row="0" />
<Space
android:layout_width="1dp"
android:layout_height="54dp"
android:layout_column="0"
android:layout_row="0" />
<Space
android:layout_width="1dp"
android:layout_height="50dp"
android:layout_column="0"
android:layout_row="11" />
<Space
android:layout_width="1dp"
android:layout_height="26dp"
android:layout_column="0"
android:layout_row="13" />
<Space
android:layout_width="1dp"
android:layout_height="58dp"
android:layout_column="0"
android:layout_row="6" />
<Space
android:layout_width="1dp"
android:layout_height="49dp"
android:layout_column="0"
android:layout_row="7" />
<Space
android:layout_width="1dp"
android:layout_height="54dp"
android:layout_column="0"
android:layout_row="8" />
<Space
android:layout_width="9dp"
android:layout_height="1dp"
android:layout_column="4"
android:layout_row="0" />
<Space
android:layout_width="1dp"
android:layout_height="59dp"
android:layout_column="0"
android:layout_row="1" />
<Space
android:layout_width="1dp"
android:layout_height="79dp"
android:layout_column="0"
android:layout_row="2" />
</GridLayout>
</ScrollView>

Output:
Program 5: Registration form designing using absolute layout

Coding:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000000" >
<AbsoluteLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:textColor="#FFFFFF"
android:gravity="center"
android:textSize="20dp"
android:text="FORM" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:layout_marginLeft="100dp"
android:layout_x="30dp"
android:layout_y="63dp"
android:text="NAME"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="50dp"
android:inputType="text" >
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="101dp"
android:layout_marginLeft="200dp"
android:layout_marginTop="400dp"
android:text="DOB"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="80dp"
android:inputType="date" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="130dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="ADDRESS"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="110dp"
android:inputType="text" >
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="160dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="PHONE NO"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="140dp"
android:inputType="text" >
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="190dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="EMAIL ID"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="170dp"
android:inputType="text" >
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="230dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="GENDER"
android:textColor="#FF00FF"
android:textSize="10dp" />
<RadioGroup
android:id="@+id/radiogroup1"
android:layout_width="154dp"
android:layout_height="wrap_content"
android:layout_x="117dp"
android:layout_y="228dp">
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:textColor="#FF00FF"
android:textSize="10dp" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FeMale"
android:textColor="#FF00FF"
android:textSize="10dp" />
</RadioGroup>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="390dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="COURSE"
android:textColor="#FF00FF"
android:textSize="10dp" />
<CheckBox
android:id="@+id/check1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="106dp"
android:layout_y="376dp"
android:text="Bsc CS"
android:textColor="#FF00FF"
android:textSize="10dp" />
<CheckBox
android:id="@+id/check2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="182dp"
android:layout_y="376dp"
android:text="Bsc IT"
android:textColor="#FF00FF"
android:textSize="10dp" />
<CheckBox
android:id="@+id/check3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="252dp"
android:layout_y="376dp"
android:text="BCA"
android:textColor="#FF00FF"
android:textSize="10dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="410dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="B;ood Group"
android:textColor="#FF00FF"
android:textSize="10dp" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="126dp"
android:layout_y="410dp"
android:entries="@array/blood"/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="119dp"
android:layout_y="437dp"
android:gravity="center"
android:text="SUBMIT"
android:textColor="#0FEEF8"
android:textSize="10dp" />
</AbsoluteLayout>
</ScrollView>

Output:
Program 6: Website creation using frame layout

Coding:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FAD717" >
<FrameLayout
android:id="@+id/framelayout"
android:layout_width="match_parent"
android:layout_height="102dp"
android:columnCount="51"
android:orientation="vertical"
android:padding="16dp"
android:background="#00418D"
android:rowCount="43" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/clglogo" />
</FrameLayout>
<FrameLayout
android:id="@+id/framelayout1"
android:layout_width="match_parent"
android:layout_height="274dp"
android:columnCount="51"
android:orientation="vertical"
android:padding="16dp"
android:rowCount="43" >
<ImageView
android:layout_width="304dp"
android:layout_height="219dp"
android:src="@drawable/vhnsnc" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_x="126dp"
android:layout_y="410dp"
android:textColor="#FF00FF"
android:entries="@array/day"/>
</FrameLayout>
<FrameLayout
android:id="@+id/framelay"
android:layout_width="match_parent"
android:layout_height="113dp"
android:columnCount="51"
android:orientation="vertical"
android:padding="16dp"
android:rowCount="92" >
<TextView
android:layout_width="match_parent"
android:layout_height="118dp"
android:layout_column="2"
android:layout_columnSpan="2"
android:layout_row="8"
android:background="#00418D"
android:paddingRight="10dp"
android:text="Low cost access to high quality education"
android:textColor="#FAD717"
android:textSize="20dp" />
</FrameLayout>
</LinearLayout>

Output:
Program 7: Displaying date using date picker

Coding:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#E44C75" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="CALENDER"
android:gravity="center"
android:textSize="30dp"/>
<DatePicker
android:id="@+id/datepicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="SUBMIT"
android:textSize="10dp" />
<AnalogClock
android:id="@+id/analogClock1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<DigitalClock
android:id="@+id/digitalClock1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DigitalClock" />
</LinearLayout>

Output:
Program 8: Login form checking

Coding:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Login form"
android:textColor="#FFFFFF"/>
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your name"
android:textColor="#FFFFFF"/>
<EditText
android:id="@+id/e2"
android:layout_width="230dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password"
android:textSize="20dp"
android:textColor="#FFFFFF"/>
<EditText
android:id="@+id/e1"
android:layout_width="230dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="submit"
android:textSize="20dp" />
</LinearLayout>

LOGIN JAVA ACTIVITY

package org.password;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.view.*;
public class PasswordActivity extends Activity {
Button button1;
EditText e1,e2;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1=(Button) findViewById(R.id.button1);
e1=(EditText) findViewById(R.id.e1);
e2=(EditText) findViewById(R.id.e2);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String username=e1.getText().toString();
String password=e2.getText().toString();
if(isValiduser(username,password))
{
showToast("valid user");
}
else
{
showToast("invalid user");
}
}
});
}
private boolean isValiduser(String username,String password)
{
return username.equals("admin") && password.equals("admin");
}
private void showToast(String message)
{
Toast.makeText(getApplicationContext(),message,Toast.LENGTH_SHORT).show();
}
}
Output:
Program 9: Calculator designing using Button

Coding:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#10CFD7" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="CALCULATOR"
android:textSize="30dp"
android:gravity="center"
android:textColor="#FFFFFF"/>
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter first value"
android:textSize="20dp"
android:textColor="#FAD717"/>
<EditText
android:id="@+id/e1"
android:layout_width="230dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter second value"
android:textSize="20dp"
android:textColor="#FAD717"/>
<EditText
android:id="@+id/e2"
android:layout_width="230dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textview3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Result"
android:textSize="20dp"
android:textColor="#FAD717"/>
<EditText
android:id="@+id/e3"
android:layout_width="230dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ADD"
android:textSize="10dp"/>
<Button
android:id="@+id/b2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SUB"
android:textSize="10dp"/>
<Button
android:id="@+id/b3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MUL"
android:textSize="10dp"/>
<Button
android:id="@+id/b4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="DIV"
android:textSize="10dp"/>
<Button
android:id="@+id/b5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MOD"
android:textSize="10dp"/>
</LinearLayout>

CALCULATOR ACTIVITY JAVA

package org.calculator;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
public class CalculatorActivity extends Activity {
EditText e1,e2,e3;
Button button1,b2,b3,b4,b5;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1=(Button) findViewById(R.id.button1);
e1=(EditText) findViewById(R.id.e1);
e2=(EditText) findViewById(R.id.e2);
e3=(EditText) findViewById(R.id.e3);
button1.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String a,b;
a=e1.getText().toString();
b=e2.getText().toString();
Integer x,y,z;
x=Integer.parseInt(a);
y=Integer.parseInt(b);
z=x+y;
String q=z.toString();
e3.setText(q);
}
});
b2=(Button) findViewById(R.id.b2);
b2.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String a,b;
a=e1.getText().toString();
b=e2.getText().toString();
Integer x,y,z;
x=Integer.parseInt(a);
y=Integer.parseInt(b);
z=x-y;
String q=z.toString();
e3.setText(q);
}
});
b3=(Button) findViewById(R.id.b3);
b3.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String a,b;
a=e1.getText().toString();
b=e2.getText().toString();
Integer x,y,z;
x=Integer.parseInt(a);
y=Integer.parseInt(b);
z=x*y;
String q=z.toString();
e3.setText(q);
}
});
b4=(Button) findViewById(R.id.b4);
b4.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String a,b;
a=e1.getText().toString();
b=e2.getText().toString();
Integer x,y,z;
x=Integer.parseInt(a);
y=Integer.parseInt(b);
z=x/y;
String q=z.toString();
e3.setText(q);
}
});
b5=(Button) findViewById(R.id.b5);
b5.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String a,b;
a=e1.getText().toString();
b=e2.getText().toString();
Integer x,y,z;
x=Integer.parseInt(a);
y=Integer.parseInt(b);
z=x%y;
String q=z.toString();
e3.setText(q);
}
});
}
}

Output:
Program 10: Program to demonstrate static intent

Coding:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
android:background="#ed6787">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Intent"
android:layout_marginLeft="150px"
android:textSize="18sp"
android:textColor="#f9ff40"
android:padding="8dp"/>
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Open Web Browser"
android:onClick="onClickWebBrowser"/>
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Make Call"
android:onClick="onMakeCalls"/>
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Show Gmail"
android:onClick="GMAIL"/>
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Open YouTube"
android:onClick="onOpenYouTube"/>
</LinearLayout>

STATIC INTENT JAVA ACTIVITY

package org.intent;
import android.content.Intent;
import android.app.Activity;
import android.os.Bundle;
import android.net.Uri;
import android.view.View;

public class IntentActivity extends Activity {


/** Called when the activity is first created. */
int request_Code = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onClickWebBrowser(View view) {
Intent i = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://www.amazon.com"));
startActivity(i);
}

public void onMakeCalls(View view) {


Intent i = new Intent(android.content.Intent.ACTION_DIAL, Uri.parse("tel:+651234567"));
startActivity(i);
}
public void GMAIL(View view)
{
Intent intent = new Intent (Intent.ACTION_VIEW, Uri.parse("https://www.gmail.com"));
startActivity(intent);
}
public void onOpenYouTube(View view)
{
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.youtube.com"));
startActivity(intent);
}
}

Output:
Program 11: Program to demonstrate dynamic intent

Coding:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000000" >
<AbsoluteLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:textColor="#FFFFFF"
android:gravity="center"
android:textSize="20dp"
android:text="FORM" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:layout_marginLeft="100dp"
android:layout_x="30dp"
android:layout_y="63dp"
android:text="NAME"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="50dp"
android:inputType="text" >
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="101dp"
android:layout_marginLeft="200dp"
android:layout_marginTop="400dp"
android:text="ROLL NO"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/edittext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="80dp"
android:inputType="text" >
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="130dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="Mark 1"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/edittext3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="110dp"
android:inputType="text" >
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="160dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="Mark 2"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/edittext4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="140dp"
android:inputType="text" >
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="314dp"
android:gravity="center"
android:text="SUBMIT"
android:textColor="#0FEEF8"
android:textSize="10dp" />
<EditText
android:id="@+id/edittext5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="143dp"
android:layout_y="193dp"
android:inputType="text" >
<requestFocus />
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:layout_x="34dp"
android:layout_y="214dp"
android:text="Mark 4"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/edittext6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="236dp"
android:inputType="text" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:layout_x="28dp"
android:layout_y="264dp"
android:text="Mark 5"
android:textColor="#FF00FF"
android:textSize="10dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:layout_x="32dp"
android:layout_y="189dp"
android:text="Mark 3"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/edittext7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="141dp"
android:layout_y="166dp"
android:inputType="text" />
</AbsoluteLayout>
</ScrollView>

DYNAMIC JAVA ACTIVITY


package org.multiplepage;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.*;
import android.widget.*;

public class multiplepageActivity extends Activity {


/** Called when the activity is first created. */
EditText m1,m2,m3,m4,m5,name,roll;
Button b1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
m1=(EditText)findViewById(R.id.edittext3);
m2=(EditText)findViewById(R.id.edittext4);
m3=(EditText)findViewById(R.id.edittext5);
m4=(EditText)findViewById(R.id.edittext6);
m5=(EditText)findViewById(R.id.edittext7);
name=(EditText)findViewById(R.id.edittext1);
roll=(EditText)findViewById(R.id.edittext2);
b1=(Button)findViewById(R.id.button1);
b1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
String studentName=name.getText().toString();
String rollNumber=roll.getText().toString();
int imark1=Integer.parseInt(m1.getText().toString());
int imark2=Integer.parseInt(m2.getText().toString());
int imark3=Integer.parseInt(m3.getText().toString());
int imark4=Integer.parseInt(m4.getText().toString());
int imark5=Integer.parseInt(m5.getText().toString());
Intent i=new Intent(multiplepageActivity.this,second.class);
i.putExtra("name",studentName);
i.putExtra("roll",rollNumber);
i.putExtra("imark1",imark1);
i.putExtra("imark2",imark2);
i.putExtra("imark3",imark3);
i.putExtra("imark4",imark4);
i.putExtra("imark5",imark5);
startActivity(i);
}
});
}
}
SECOND.XML
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000000" >
<AbsoluteLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="130dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="Mark 1"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/e1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="110dp"
android:inputType="text" >
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="160dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="Mark 2"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/e2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="140dp"
android:inputType="text" >
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="314dp"
android:gravity="center"
android:text="SUBMIT"
android:textColor="#0FEEF8"
android:textSize="10dp" />
<EditText
android:id="@+id/e3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="143dp"
android:layout_y="193dp"
android:inputType="text" >
<requestFocus />
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:layout_x="34dp"
android:layout_y="214dp"
android:text="Mark 4"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/e4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="236dp"
android:inputType="text" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:layout_x="28dp"
android:layout_y="264dp"
android:text="Mark 5"
android:textColor="#FF00FF"
android:textSize="10dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:layout_x="32dp"
android:layout_y="189dp"
android:text="Mark 3"
android:textColor="#FF00FF"
android:textSize="10dp" />
<EditText
android:id="@+id/e5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="141dp"
android:layout_y="166dp"
android:inputType="text" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="182dp"
android:layout_y="310dp"
android:gravity="center"
android:text="BACK"
android:textColor="#0FEEF8"
android:textSize="10dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_marginTop="50dp"
android:layout_x="2dp"
android:layout_y="55dp"
android:gravity="center"
android:text="External"
android:textColor="#FFFFFF"
android:textSize="20dp" />
</AbsoluteLayout>
</ScrollView>
SECOND.JAVA
package org.multiplepage;

import android.app.Activity;
import android.content.*;
import android.os.Bundle;
import android.view.*;
import android.widget.*;

public class second extends Activity {


EditText em1,em2,em3,em4,em5;
String studentName;
String rollNumber;
Button b1,b2;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
em1=(EditText)findViewById(R.id.e1);
em2=(EditText)findViewById(R.id.e2);
em3=(EditText)findViewById(R.id.e3);
em4=(EditText)findViewById(R.id.e4);
em5=(EditText)findViewById(R.id.e5);
b1=(Button)findViewById(R.id.button1);
b2=(Button)findViewById(R.id.button2);
b1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
int emark1=Integer.parseInt(em1.getText().toString());
int emark2=Integer.parseInt(em2.getText().toString());
int emark3=Integer.parseInt(em3.getText().toString());
int emark4=Integer.parseInt(em4.getText().toString());
int emark5=Integer.parseInt(em5.getText().toString());
Intent intent=getIntent();
studentName=intent.getStringExtra("name");
rollNumber=intent.getStringExtra("roll");
int imark1=intent.getIntExtra("imark1",0);
int imark2=intent.getIntExtra("imark2",0);
int imark3=intent.getIntExtra("imark3",0);
int imark4=intent.getIntExtra("imark4",0);
int imark5=intent.getIntExtra("imark5",0);
int
total=imark1+imark2+imark3+imark4+imark5+emark1+emark2+emark3+emark4+emark5;
double average=total/5.0;
Intent i=new Intent(second.this,third.class);
i.putExtra("name",studentName);
i.putExtra("roll", rollNumber);
i.putExtra("total",total);
i.putExtra("average", average);
startActivity(i);
}
});
b2.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
Intent result=new Intent(second.this,multiplepageActivity.class);
startActivity(result);
}
});
}
}

THIRD.XML
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000000" >
<AbsoluteLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:textColor="#FFFFFF"
android:gravity="center"
android:textSize="20dp"
android:text="FORM" />
<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:layout_marginLeft="100dp"
android:layout_x="30dp"
android:layout_y="63dp"
android:text="NAME"
android:textColor="#FF00FF"
android:textSize="10dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="101dp"
android:layout_marginLeft="200dp"
android:layout_marginTop="400dp"
android:text="ROLL NO"
android:textColor="#FF00FF"
android:textSize="10dp" />
<TextView
android:id="@+id/textView4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="130dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:text="Total"
android:textColor="#FF00FF"
android:textSize="10dp" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="314dp"
android:gravity="center"
android:text="Back"
android:textColor="#0FEEF8"
android:textSize="10dp" />
<TextView
android:id="@+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="400dp"
android:layout_x="31dp"
android:layout_y="170dp"
android:text="Average"
android:textColor="#FF00FF"
android:textSize="10dp" />
</AbsoluteLayout>
</ScrollView>

THIRD.JAVA
package org.multiplepage;

import android.app.Activity;
import android.content.*;
import android.os.Bundle;
import android.view.*;
import android.widget.*;

public class third extends Activity{


public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
Intent intent=getIntent();
String s1=intent.getStringExtra("name");
String r1=intent.getStringExtra("roll");
TextView textviewname=(TextView)findViewById(R.id.textView2);
TextView textviewroll=(TextView)findViewById(R.id.textView3);
int total=getIntent().getIntExtra("total",0);
double average=getIntent().getDoubleExtra("average",0.0);
TextView textviewtotal=(TextView)findViewById(R.id.textView4);
TextView textviewaverage=(TextView)findViewById(R.id.textView5);
textviewtotal.setText("Total Mark "+total);
textviewroll.setText("Roll Number "+r1);
textviewname.setText("Student Name "+s1);
textviewaverage.setText("Average "+average);
Button b1=(Button)findViewById(R.id.button1);
b1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v){


// TODO Auto-generated method stub
Intent i=new Intent(third.this,multiplepageActivity.class);
startActivity(i);
}
});
}
}

Output:
Program 12: Program to Prepare quiz using Radio Button

Coding:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CAC4C4"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
android:background="#00C2DE">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="QUIZ"
android:textColor="#009999"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What is the capital of India?"
android:textSize="18sp"
android:textColor="#000000"
android:layout_marginBottom="8dp" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio1"
android:text="Tamil Nadu"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio2"
android:text="Delhi"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio3"
android:text="Maharashtra"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio4"
android:text="Andhra Pradesh"
android:textColor="#000000"/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What is the national bird?"
android:textSize="18sp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:textColor="#000000" />
<RadioGroup
android:id="@+id/radioGroup2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radio5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio5"
android:text="Parrot"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio6"
android:text="Peacock"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio7"
android:text="Dove"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio8"
android:text="Pigeon"
android:textColor="#000000"/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What is the largest planet in our Solar System?"
android:textSize="18sp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:textColor="#000000" />
<RadioGroup
android:id="@+id/radioGroup3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radio9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio9"
android:text="Jupiter"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio10"
android:text="Saturn"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio11"
android:text="Mercury"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio12"
android:text="Mars"
android:textColor="#000000"/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" What is the national animal?"
android:textSize="18sp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:textColor="#000000"/>
<RadioGroup
android:id="@+id/radioGroup4"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radio13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio13"
android:text="Lion"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio14"
android:text="Tiger"
android:textColor="#000000" />
<RadioButton
android:id="@+id/radio15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio15"
android:text="Cheetah"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio16"
android:text="Leopard"
android:textColor="#000000"/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What is the national flower?"
android:textSize="18sp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:textColor="#000000"/>
<RadioGroup
android:id="@+id/radioGroup5"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radio17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio17"
android:text="Jasmine"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio18"
android:text="Lotus"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio19"
android:text="Tulip"
android:textColor="#000000"/>
<RadioButton
android:id="@+id/radio20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="radio20"
android:text="Hibiscus"
android:textColor="#000000"/>
</RadioGroup>
<Button
android:id="@+id/button1"
android:layout_width="268dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Submit" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Result "
android:layout_marginTop="16dp"
android:textSize="18sp"
android:textColor="#000000" />
</LinearLayout>
</ScrollView>

QUIZ.JAVA
package org.quiz;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

public class QuizActivity extends Activity {


RadioGroup[] radioGroups;
TextView resultTextView;
int mark = 0;
String[] answers = {"radio2", "radio6", "radio9", "radio14", "radio18"};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button submitButton = (Button) findViewById(R.id.button1);


radioGroups = new RadioGroup[]{
(RadioGroup) findViewById(R.id.radioGroup1),
(RadioGroup) findViewById(R.id.radioGroup2),
(RadioGroup) findViewById(R.id.radioGroup3),
(RadioGroup) findViewById(R.id.radioGroup4),
(RadioGroup) findViewById(R.id.radioGroup5)
};
resultTextView = (TextView) findViewById(R.id.textView6);

submitButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mark = 0;

for (int i = 0; i < radioGroups.length; i++) {


int selectedId = radioGroups[i].getCheckedRadioButtonId();
RadioButton selectedButton = (RadioButton) findViewById(selectedId);
if (selectedButton != null && selectedButton.getTag() != null &&
selectedButton.getTag().toString().equals(answers[i])) {
mark++;
}
}

String result = "Result is: " + mark;


resultTextView.setText(result);
}
});
}
}

Output:
Program 13: Program to Perform string operations

Coding:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="321dp"
android:layout_height="match_parent"
android:background="#E3C0F5"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="14"
android:layout_marginTop="10dp"
android:layout_row="0"
android:gravity="center"
android:text="STRING OPERATIONS"
android:textColor="#000000"
android:textSize="20dp" />
<RadioGroup
android:id="@+id/rr1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="6"
android:layout_row="2" >
</RadioGroup>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="6"
android:layout_marginLeft="115dp"
android:layout_marginTop="440dp"
android:layout_row="3"
android:layout_rowSpan="15"
android:gravity="center"
android:text="Length" />
<RadioGroup
android:id="@+id/rr2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_column="0"
android:layout_columnSpan="5"
android:layout_row="6" >
</RadioGroup>
<RadioGroup
android:id="@+id/rr3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_column="0"
android:layout_columnSpan="5"
android:layout_row="11" >
</RadioGroup>
<Button
android:id="@+id/button4"
android:layout_column="0"
android:layout_columnSpan="14"
android:layout_gravity="center_horizontal"
android:layout_row="15"
android:text="Button" />
<TextView
android:id="@+id/textView1"
android:layout_column="1"
android:layout_columnSpan="2"
android:layout_marginTop="40dp"
android:layout_row="4"
android:text="Enter 1st String :"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
<TextView
android:id="@+id/textView2"
android:layout_column="1"
android:layout_columnSpan="2"
android:layout_gravity="bottom"
android:layout_marginTop="60dp"
android:layout_row="5"
android:text="Enter 2nd String :"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
<Button
android:id="@+id/button2"
android:layout_column="2"
android:layout_gravity="bottom|right"
android:layout_marginLeft="-50dp"
android:layout_marginTop="80dp"
android:layout_row="7"
android:layout_rowSpan="5"
android:text="String concatenation" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_column="2"
android:layout_gravity="left"
android:layout_marginLeft="-100dp"
android:layout_marginTop="20dp"
android:layout_row="8"
android:text="Result"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/e2"
android:layout_width="130dp"
android:layout_column="2"
android:layout_columnSpan="2"
android:layout_marginLeft="73dp"
android:layout_marginTop="-160dp"
android:layout_row="12"
android:layout_rowSpan="2" />
<Button
android:id="@+id/button3"
android:layout_column="2"
android:layout_gravity="left"
android:layout_marginLeft="-10dp"
android:layout_row="13"
android:text="Sub String" />
<Button
android:id="@+id/button5"
android:layout_column="2"
android:layout_gravity="left"
android:layout_marginLeft="-30dp"
android:layout_row="15"
android:text="String Compare" />
<Button
android:id="@+id/button6"
android:layout_column="2"
android:layout_gravity="left"
android:layout_marginLeft="1dp"
android:layout_marginTop="35dp"
android:layout_row="16"
android:text="Reverse" />
<EditText
android:id="@+id/e1"
android:layout_width="130dp"
android:layout_column="3"
android:layout_columnSpan="2"
android:layout_marginLeft="-70dp"
android:layout_marginTop="-30dp"
android:layout_row="5" >
<requestFocus />
</GridLayout>

</ScrollView>

STRING.JAVA
package org.string;

import android.app.Activity;
import android.view.*;
import android.os.Bundle;
import android.widget.*;
public class StringActivity extends Activity {
/** Called when the activity is first created. */
TextView t1;
EditText e1,e2;
Button b1,b2,b3,b4,b5;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b1=(Button)findViewById(R.id.button2);
b2=(Button)findViewById(R.id.button3);
b3=(Button)findViewById(R.id.button5);
b4=(Button)findViewById(R.id.button1);
b5=(Button)findViewById(R.id.button6);
e1=(EditText)findViewById(R.id.e1);
e2=(EditText)findViewById(R.id.e2);
t1=(TextView)findViewById(R.id.textView3);
b1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
String s1=e1.getText().toString();
String s2=e2.getText().toString();
t1.setText("CONCATENATION : "+
s1.concat(s2));//s1/concat(s2)
}
});
b2.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
String s1=e1.getText().toString();
int s3=Integer.parseInt(e2.getText().toString());
t1.setText("SubString : "+s1.substring(s3));
}
});
b3.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
String s1=e1.getText().toString();
String s2=e2.getText().toString();
if (s1.equals(s2))
t1.setText("Two String are Equals");
else
t1.setText("Two String Not are Equals");
}
});
b4.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
String s1=e1.getText().toString();

t1.setText("Length of String : "+s1.length());


}
});
b5.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
String s1=e1.getText().toString();
StringBuffer s2=new StringBuffer(s1);
t1.setText("Length of String : "+s2.reverse());
}
});
}
}

Output:
Program 14: Program to create age calculator using date picker
Coding:

<?xml version="1.0" encoding="utf-8"?>


<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:text="" />

<DatePicker
android:id="@+id/datePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="38dp"
android:layout_y="371dp"
android:text="TextView" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="42dp"
android:layout_y="408dp"
android:text="TextView" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="44dp"
android:layout_y="440dp"
android:text="TextView" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="110dp"
android:layout_y="292dp"
android:text="Submit" />

</AbsoluteLayout>

AGE.JAVA
package org.age;

import java.util.Calendar;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;

public class AgeActivity extends Activity {


Calendar c1=Calendar.getInstance();
DatePicker d1;
TextView t1,t2,t3;
Button b1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
d1=(DatePicker)findViewById(R.id.datePicker1);
t1=(TextView)findViewById(R.id.textView1);
t2=(TextView)findViewById(R.id.textView2);
t3=(TextView)findViewById(R.id.textView3);
b1=(Button)findViewById(R.id.button1);
b1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
int date=0,month=0,year=0;
int cdate=0,cmonth=0,cyear=0;
int d=0,m=0,y=0;
date=d1.getDayOfMonth();
month=d1.getMonth();
year=d1.getYear();
cdate=c1.get(Calendar.DAY_OF_MONTH);
cmonth=c1.get(Calendar.MONTH);
cyear=c1.get(Calendar.YEAR);
StringBuilder s=new StringBuilder();
if(cdate<date){

cdate+=c1.getActualMaximum(Calendar.DAY_OF_MONTH);
cmonth-=1;
}
if(cmonth<month){
cmonth+=12;
cyear-=1;
}
d=Math.abs(cdate-date);

m=Math.abs(cmonth-month);
y=Math.abs(cyear-year);
s.append("Current Date is");

s.append(Calendar.getInstance().get(Calendar.DAY_OF_MONTH)
+":"+Calendar.getInstance().get(Calendar.MONTH)
+":"+Calendar.getInstance().get(Calendar.YEAR));
StringBuilder s1=new StringBuilder();
s1.append("Your DOB is");
s1.append(date+":"+month+":"+year);
StringBuilder s2=new StringBuilder();
s2.append("Age:"+d+"Days :"+m+"Months :"+y+"year");
t1.setText(s.toString());
t2.setText(s1.toString());
t3.setText(s2.toString());

}
});
}
}

Output:
Program 15: Program to create bill calculation using checkbox

Coding:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
android:background="#FFFFFF">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:text="CALCULATION"
android:textSize="20dp"
android:layout_marginLeft="60dp"
android:textColor="#009900"
android:layout_marginBottom="16dp"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">

<CheckBox
android:id="@+id/checkBox1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Apple"
android:textColor="#cc33ff" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs.200"
android:textColor="#5F2879"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical" />

<EditText
android:id="@+id/editTextQuantity1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="#000000"
android:hint="Quantity"
android:inputType="number"
android:textColor="#000000"
android:layout_gravity="center_vertical" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">

<CheckBox
android:id="@+id/checkBox2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Mango"
android:textColor="#cc33ff" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs.100"
android:textColor="#5F2879"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical" />

<EditText
android:id="@+id/editTextQuantity2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="#000000"
android:hint="Quantity"
android:textColor="#000000"
android:inputType="number"
android:layout_gravity="center_vertical" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">

<CheckBox
android:id="@+id/checkBox3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Grapes"
android:textColor="#cc33ff" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs.150"
android:textColor="#5F2879"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical" />

<EditText
android:id="@+id/editTextQuantity3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="#000000"
android:hint="Quantity"
android:textColor="#000000"
android:inputType="number"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">

<CheckBox
android:id="@+id/checkBox4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Guva"
android:textColor="#cc33ff" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs.50"
android:textColor="#5F2879"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical" />

<EditText
android:id="@+id/editTextQuantity4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="#000000"
android:hint="Quantity"
android:textColor="#000000"
android:inputType="number"
android:layout_gravity="center_vertical" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">

<CheckBox
android:id="@+id/checkBox5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Orange"
android:textColor="#cc33ff" />

<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs.70"
android:textColor="#5F2879"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical" />

<EditText
android:id="@+id/editTextQuantity5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="#000000"
android:hint="Quantity"
android:textColor="#000000"
android:inputType="number"
android:layout_gravity="center_vertical" />
</LinearLayout>

<Button
android:id="@+id/submitButton"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="80dp"
android:text="Submit"
android:textColor="#000000" />

<TextView
android:id="@+id/totalTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Total: ₹"
android:textColor="#9933ff"
android:textSize="20dp"
android:paddingTop="16dp" />
</LinearLayout>

CHECKBOX.JAVA
package org.checkbox;

import android.app.Activity;
import android.app.AliasActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

public class CheckboxActivity extends Activity {

private CheckBox checkBox1, checkBox2, checkBox3,checkBox4,checkBox5;


private EditText editTextQuantity1, editTextQuantity2,
editTextQuantity3,editTextQuantity4,editTextQuantity5;
private Button submitButton;
private TextView totalTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

checkBox1 = (CheckBox) findViewById(R.id.checkBox1);


checkBox2 = (CheckBox) findViewById(R.id.checkBox2);
checkBox3 = (CheckBox) findViewById(R.id.checkBox3);
checkBox4=(CheckBox) findViewById(R.id.checkBox4);
checkBox5=(CheckBox) findViewById(R.id.checkBox5);
editTextQuantity1 = (EditText) findViewById(R.id.editTextQuantity1);
editTextQuantity2 = (EditText) findViewById(R.id.editTextQuantity2);
editTextQuantity3 = (EditText) findViewById(R.id.editTextQuantity3);
editTextQuantity4 = (EditText) findViewById(R.id.editTextQuantity4);
editTextQuantity5 = (EditText) findViewById(R.id.editTextQuantity5);
submitButton = (Button) findViewById(R.id.submitButton);
totalTextView = (TextView) findViewById(R.id.totalTextView);

submitButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int total = 0;

if (checkBox1.isChecked()) {
int quantity1 = Integer.parseInt(editTextQuantity1.getText().toString());
total += 200 * quantity1;
}
if (checkBox2.isChecked()) {
int quantity2 = Integer.parseInt(editTextQuantity2.getText().toString());
total += 100 * quantity2;
}
if (checkBox3.isChecked()) {
int quantity3 = Integer.parseInt(editTextQuantity3.getText().toString());
total += 150 * quantity3;
}
if (checkBox4.isChecked()) {
int quantity4 = Integer.parseInt(editTextQuantity4.getText().toString());
total += 50 * quantity4;
}
if (checkBox5.isChecked()) {
int quantity5 = Integer.parseInt(editTextQuantity5.getText().toString());
total += 70 * quantity5;
}

totalTextView.setText("Total: ₹" + total);


}
});
}
}

Output:
Program 16: Program to create menu options
Coding:

<?xml version="1.0" encoding="utf-8"?>


<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#00C2DE">

<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="2dp"
android:layout_y="7dp"
android:gravity="center"
android:text="CONTEXT MENU"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />

<ImageButton
android:id="@+id/imageButton1"
android:layout_width="230dp"
android:layout_height="237dp"
android:layout_x="48dp"
android:layout_y="102dp"
android:src="@drawable/chocolate"
android:background="#000000"
android:scaleType="fitXY" />
</AbsoluteLayout>
IMAGE.JAVA
package org.image;

import android.app.Activity;
import android.os.Bundle;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
import android.view.ContextMenu.ContextMenuInfo;

public class ImageActivity extends Activity {


ImageView i1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
i1 = (ImageView)findViewById(R.id.imageButton1);
i1.setOnCreateContextMenuListener(this);
}
public void onCreateContextMenu(ContextMenu cm,View v,ContextMenuInfo cmi)
{
super.onCreateContextMenu(cm, v, cmi);
cm.setHeaderTitle("Context Menu");
cm.add(0,v.getId(),0,"Save");
cm.add(0,v.getId(),0,"Cut");
cm.add(0,v.getId(),0,"Copy");
cm.add(0,v.getId(),0,"Paste");
cm.add(0,v.getId(),0,"Delete");
}
public boolean onContextItemSelected(MenuItem mi)
{
if(mi.getTitle()=="Save")
Toast.makeText(getBaseContext(),"Save
Success",Toast.LENGTH_SHORT).show();
else if(mi.getTitle()=="Cut")
Toast.makeText(getBaseContext(),"Cut
Success",Toast.LENGTH_SHORT).show();
else if(mi.getTitle()=="Copy")
Toast.makeText(getBaseContext(),"Copied
Successfully",Toast.LENGTH_SHORT).show();
else if(mi.getTitle()=="Paste")

Toast.makeText(getBaseContext(),"Done",Toast.LENGTH_SHORT).show();
else if(mi.getTitle()=="Delete")
Toast.makeText(getBaseContext(),"Deleted
Successfully",Toast.LENGTH_SHORT).show();
else
return false;
return true;
}
}

Output:
Program 17: Program to perform array operations
Coding:

<?xml version="1.0" encoding="utf-8"?>


<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#CCFFFF" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="108dp"
android:layout_y="9dp"
android:text="Array function"
android:textColor="#FF00FF"/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="18dp"
android:layout_y="50dp"
android:text="Number of elements"
android:textColor="#FF00FF" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="21dp"
android:layout_y="102dp"
android:text="Value of numbers(,)"
android:textColor="#FF00FF" />

<EditText
android:id="@+id/editText1"
android:layout_width="98dp"
android:layout_height="wrap_content"
android:layout_x="157dp"
android:layout_y="47dp"
android:textColor="#000000" >
<requestFocus />
</EditText>

<EditText
android:id="@+id/editText2"
android:layout_width="108dp"
android:layout_height="wrap_content"
android:layout_x="151dp"
android:layout_y="102dp"
android:textColor="#000000" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="94dp"
android:layout_y="144dp"
android:text="SUBMIT"
android:textColor="#0FEEF8" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="23dp"
android:layout_y="208dp"
android:text="TextView"
android:textColor="#FF00FF"/>

<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="21dp"
android:layout_y="249dp"
android:text="TextView"
android:textColor="#FF00FF" />

<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="16dp"
android:layout_y="294dp"
android:text="TextView"
android:textColor="#FF00FF" />

<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="334dp"
android:text="TextView"
android:textColor="#FF00FF" />

<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="12dp"
android:layout_y="379dp"
android:text="TextView"
android:textColor="#FF00FF" />

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="15dp"
android:layout_y="431dp"
android:text="TextView"
android:textColor="#FF00FF"/>

</AbsoluteLayout>
ARRAY.JAVA
package org.array;

import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.widget.*;

public class ArrayActivity extends Activity {


/** Called when the activity is first created. */
Button b1;
EditText e1,e2;
TextView t1,t2,t3,t4,t5,t6;
int a[];
StringBuilder s1=new StringBuilder();

public void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b1=(Button)findViewById(R.id.button1);
e1=(EditText)findViewById(R.id.editText1);
e2=(EditText)findViewById(R.id.editText2);
t1=(TextView)findViewById(R.id.textView4);
t2=(TextView)findViewById(R.id.textView5);
t3=(TextView)findViewById(R.id.textView6);
t4=(TextView)findViewById(R.id.textView7);
t5=(TextView)findViewById(R.id.textView8);
t6=(TextView)findViewById(R.id.textView9);
b1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


// TODO Auto-generated method stub
int size=Integer.parseInt(e1.getText().toString());
int a[]=new int[size];
String value[]=e2.getText().toString().split(",");
if(value.length!=size)
{
Toast.makeText(getApplicationContext(), "Array index out
of bound Exception",Toast.LENGTH_LONG).show();

}
else
{
for(int i=0;i<size;i++)
{
a[i]=Integer.parseInt(value[i]);
}
t1.setText("Array Length is : "+Integer.toString(a.length));
reverse(a);
small(a);
big(a);
asec(a);
desec(a);
}
}
});
}
public void reverse(int a[])
{
StringBuilder s1=new StringBuilder();
for(int i=a.length-1;i>=0;i--)
{
s1.append(Integer.toString(a[i]));
if(i>0)
{
s1.append(",");
}

}
t2.setText("Reverse is "+s1.toString());
}
public void big(int a[])
{
int big=a[0];
for(int i=0;i<a.length;i++)
{
if(a[i]>big)
{
big=a[i];
}
}
t3.setText("Biggest element "+Integer.toString(big));
}
public void small(int a[])
{
int small=a[0];
for(int i=0;i<a.length;i++)
{
if(a[i]<small)
{
small=a[i];
}
}
t4.setText("Smallest element "+Integer.toString(small));
}
public void asec(int a[])
{
for(int i=0;i<a.length;i++)
{
for(int j=0;j<a.length;j++)
{
if(a[i]<a[j])
{
int t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
StringBuilder s1=new StringBuilder();
s1.append("Ascending order");
for(int i=0;i<a.length;i++)
{
s1.append(Integer.toString(a[i]));
if(i<a.length-1)
{
s1.append(",");

}
}
t5.setText(s1.toString());
}
public void desec(int a[])
{
for(int i=0;i<a.length;i++)
{
for(int j=0;j<a.length;j++)
{
if(a[i]>a[j])
{
int t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
StringBuilder s1=new StringBuilder();
s1.append("Descenging order");
for(int i=0;i<a.length;i++)
{
s1.append(Integer.toString(a[i]));
if(i<a.length-1)
{
s1.append(",");
}
}
t6.setText(s1.toString());
}
}

Output:
Program 18: Program to insert and retrieve student details using
database

Coding:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#5F2879" >

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="33dp"
android:layout_y="216dp"
android:text="Java" />

<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="266dp"
android:text="Python" />

<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="33dp"
android:layout_y="310dp"
android:text="C++" />

<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="32dp"
android:layout_y="354dp"
android:text="Amdroid" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="50dp"
android:layout_y="394dp"
android:text="ADD" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="171dp"
android:layout_y="388dp"
android:text="VIEW" />

<EditText
android:id="@+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="50dp"
android:inputType="text" >

</EditText>

<EditText
android:id="@+id/edittext4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="139dp"
android:layout_y="200dp"
android:inputType="text" />

<EditText
android:id="@+id/edittext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="143dp"
android:layout_y="112dp"
android:inputType="text" >

<requestFocus />
</EditText>

<EditText
android:id="@+id/edittext5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="140dp"
android:layout_y="252dp"
android:inputType="text" />

<EditText
android:id="@+id/edittext3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="143dp"
android:layout_y="162dp"
android:inputType="text" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="30dp"
android:layout_y="179dp"
android:text="C" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="33dp"
android:layout_y="135dp"
android:text="Roll Number" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="31dp"
android:layout_y="72dp"
android:text="Name" />

<EditText
android:id="@+id/edittext6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="138dp"
android:layout_y="298dp"
android:inputType="text" />

<EditText
android:id="@+id/edittext7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="136dp"
android:layout_y="340dp"
android:inputType="text" />

</AbsoluteLayout>

STUDENT.JAVA
package org.database;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.*;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
public class DatabaseActivity extends Activity {
/** Called when the activity is first created. */
EditText e1,e2,e3,e4,e5,e6,e7;
Button b1,b2;
SQLiteDatabase db;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
e1=(EditText)findViewById(R.id.edittext1);
e2=(EditText)findViewById(R.id.edittext2);
e3=(EditText)findViewById(R.id.edittext3);
e4=(EditText)findViewById(R.id.edittext4);
e5=(EditText)findViewById(R.id.edittext5);
e6=(EditText)findViewById(R.id.edittext6);
e7=(EditText)findViewById(R.id.edittext7);
b1=(Button)findViewById(R.id.button1);
b2=(Button)findViewById(R.id.button2);
db = openOrCreateDatabase("studentsDB", Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS students1(name VARCHAR, rollno
VARCHAR, c VARCHAR, java VARCHAR, python VARCHAR, adc VARCHAR, android
VARCHAR);");

b1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


String name = e1.getText().toString();
String rollno = e2.getText().toString();
String c = e3.getText().toString();
String java= e4.getText().toString();
String python= e5.getText().toString();
String adc = e6.getText().toString();
String android = e7.getText().toString();
db.execSQL("INSERT INTO students1 VALUES('" + name + "', '" + rollno + "', '" + c
+ "', '" + java + "', '" + python + "', '" + adc + "', '" + android + "');");
showMessage("Success", "Record added");
clearText();
}
});

b2.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


Cursor c = db.rawQuery("SELECT * FROM students1", null);
if (c.getCount() == 0) {
showMessage("Error", "No record found");
return;
}
StringBuffer str = new StringBuffer();
while (c.moveToNext()) {
str.append("\n\n Student Name = " + c.getString(0));
str.append("\n Student RollNo = " + c.getString(1));
str.append("\n C = " + c.getString(2));
str.append("\n Java = " + c.getString(3));
str.append("\n Python = " + c.getString(4));
str.append("\n c++ = " + c.getString(5));
str.append("\n Android = " + c.getString(6));
}
showMessage("Student Result", str.toString());
}
});
}

public void showMessage(String title, String message) {


AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(message);
builder.show();
}

public void clearText() {


e1.setText("");
e2.setText("");
e3.setText("");
e4.setText("");
e5.setText("");
e6.setText("");
e7.setText("");
}
}

Output:
Program 19: Program to perform electricity bill calculations using
database.

Coding:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/texteview8"
android:layout_width="172dp"
android:layout_height="wrap_content"
android:layout_x="64dp"
android:layout_y="13dp"
android:text="EB Bill calculation" />

<TextView
android:id="@+id/texteview1"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:layout_x="3dp"
android:layout_y="54dp"
android:text="User Name :" />

<EditText
android:id="@+id/e1"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_x="149dp"
android:layout_y="44dp"
android:inputType="text" />

<TextView
android:id="@+id/texteview2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_x="0dp"
android:layout_y="120dp"
android:text="User ID :" />

<EditText
android:id="@+id/e2"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_x="148dp"
android:layout_y="100dp"
android:inputType="text" />

<TextView
android:id="@+id/texteview3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="1dp"
android:layout_y="174dp"
android:text="Previous unit :" />
<EditText
android:id="@+id/e3"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_x="153dp"
android:layout_y="158dp"
android:inputType="text" />

<TextView
android:id="@+id/texteview4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="0dp"
android:layout_y="222dp"
android:text="Current unit :" />

<EditText
android:id="@+id/e5"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_x="159dp"
android:layout_y="204dp"
android:inputType="text" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="194dp"
android:layout_y="271dp"
android:gravity="center"
android:text="VIEW"
android:textColor="#00BA71" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="22dp"
android:layout_y="275dp"
android:gravity="center"
android:text="ADD"
android:textColor="#00BA71" />

</AbsoluteLayout>
Eb.java
package org.eb;

import org.eb.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class EbActivity extends Activity {


/** Called when the activity is first created. */
EditText e1,e2,e3,e5;
Button b1,b2;
SQLiteDatabase db;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
e1=(EditText)findViewById(R.id.e1);
e2=(EditText)findViewById(R.id.e2);
e3=(EditText)findViewById(R.id.e3);
e5=(EditText)findViewById(R.id.e5);
b1=(Button)findViewById(R.id.button1);
b2=(Button)findViewById(R.id.button2);
db = openOrCreateDatabase("ebbillDB", Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS eb(uname VARCHAR, userid
VARCHAR, previous VARCHAR, current VARCHAR, cunit VARCHAR, amount
VARCHAR);");

b1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


String uname = e1.getText().toString();
String uid = e2.getText().toString();
String pre = e3.getText().toString();
String cur = e5.getText().toString();
Integer a=Integer.parseInt(pre);
Integer b=Integer.parseInt(cur);
Integer c=b-a;
Integer amt;
if(c<=100)
{
amt=0;
}
else if(c<=200)
{
amt=(c-100)*2;
}
else if(c<=300)
{
amt=(c-100)*3;
}
else if(c<=400)
{
amt=(c-100)*4;
}
else
{
amt=(c-100)*5;
}
db.execSQL("INSERT INTO eb VALUES('" + uname + "', '" + uid + "', '" +pre+ "', '"
+ cur + "', '" +c + "', '" +amt + "');");
showMessage("Success", "Record added");
clearText();
}
});

b2.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {


Cursor c = db.rawQuery("SELECT * FROM eb", null);
if (c.getCount() == 0) {
showMessage("Error", "No record found");
return;
}
StringBuffer str = new StringBuffer();
while (c.moveToNext()) {
str.append("\n\n UserName = " + c.getString(0));
str.append("\n User ID = " + c.getString(1));
str.append("\n Previus unit = " + c.getString(2));
str.append("\n Current unit = " + c.getString(3));
str.append("\n Consumed unnit= " + c.getString(4));
str.append("\n Total amount = " + c.getString(5));
}
showMessage("EB Bill", str.toString());
}
});
}

public void showMessage(String title, String message) {


AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(message);
builder.show();
}

public void clearText() {


e1.setText("");
e2.setText("");
e3.setText("");
e5.setText("");
}
}
Output:

You might also like