0% found this document useful (0 votes)
12 views36 pages

MAD practical program

The document outlines practical exercises for mobile application development, showcasing XML layouts for various user interface components. It includes examples of LinearLayout, TableLayout, and AbsoluteLayout with TextViews and EditTexts for user input. The exercises focus on creating simple applications that display user information and data types.

Uploaded by

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

MAD practical program

The document outlines practical exercises for mobile application development, showcasing XML layouts for various user interface components. It includes examples of LinearLayout, TableLayout, and AbsoluteLayout with TextViews and EditTexts for user input. The exercises focus on creating simple applications that display user information and data types.

Uploaded by

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

Mobile Application Development

Practical No: 4
X. Exercise
1.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android ="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="350dp"
android:textColor="#000000"
android:textSize="30dp"
android:textStyle="italic"/>
</LinearLayout>

Output

2.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
tools:context=".MainActivity">
<TableRow
android:background="#F52887"

Practical No:
Mobile Application Development

android:padding="5dp" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=" StudentName"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Subject1"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Subject2"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Subject3"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

</TableRow>

<TableRow
android:padding="5dp" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ajay"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"

Practical No:
Mobile Application Development

android:layout_weight="1"
android:text="60"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="55"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="69"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

</TableRow>

</TableLayout>

Output

Practical No:
Mobile Application Development

Practical No: 5
X. Exercise

1.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#CCEEFF"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name :"
android:textSize="30dp"
android:layout_marginTop="40dp"
android:layout_marginLeft="10dp"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Your Name"
android:layout_marginTop="10dp”/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age :"
android:textSize="30dp"
android:layout_marginTop="40dp"
android:layout_marginLeft="10dp”/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Your Age"
android:layout_marginTop="10dp"/>

<TextView
android:layout_width="wrap_content"

Practical No:
Mobile Application Development

android:layout_height="wrap_content"
android:text="Mobile No :"
android:textSize="30dp"
android:layout_marginTop="40dp"
android:layout_marginLeft="10dp"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Your Mobile No. "
android:layout_marginTop="10dp"/>
</LinearLayout>

Output

2.
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#98AFC7"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name :"
android:textSize="30dp"
android:layout_x="1dp"
android:layout_y="71dp"
android:layout_marginTop="50dp"
android:layout_marginLeft="10dp"
android:textColor="#000000"/>

<EditText
android:layout_width="match_parent"

Practical No:
Mobile Application Development

android:layout_height="wrap_content"
android:hint="Enter Your Name"
android:layout_marginTop="10dp"
android:layout_x="2dp"
android:layout_y="101dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age :"
android:textSize="30dp"
android:layout_marginTop="40dp"
android:layout_marginLeft="10dp"
android:layout_x="1dp"
android:layout_y="146dp"
android:textColor="#000000"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Your Age"
android:layout_marginTop="10dp"
android:layout_x="1dp"
android:layout_y="177dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile No :"
android:textSize="30dp"
android:layout_marginTop="40dp"
android:layout_marginLeft="10dp"
android:layout_x="2dp"
android:layout_y="227dp"
android:textColor="#000000"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Your Mobile No. "
android:layout_marginTop="10dp"
android:layout_x="2dp"
android:layout_y="260dp"/>
</AbsoluteLayout>

Output

Practical No:
Mobile Application Development

Practical No:
Mobile Application Development

Practical No: 6
X. Exercise

1.

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


<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="200dp"
tools:context=".MainActivity">
<TableRow
android:background="#F52887"
android:padding="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Name"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Age"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView

Practical No:
Mobile Application Development

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Mobile No."
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Address"
android:layout_marginLeft="10dp"
android:textSize="15dp" />
</TableRow>
<TableRow

android:padding="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ajay"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="18"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9854439274"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Nashik"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>
</TableRow>

Practical No:
Mobile Application Development

<TableRow

android:padding="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Jack"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="20"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="8843527130"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Mumbai"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

</TableRow>

<TableRow

android:padding="5dp" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Sameer"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"

Practical No:
Mobile Application Development

android:layout_height="wrap_content"
android:layout_weight="1"
android:text="19"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9912674903"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Pune"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

</TableRow>

<TableRow

android:padding="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Nikita"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="18"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="8723649218"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

Practical No:
Mobile Application Development

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Shimla"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

</TableRow>
<TableRow

android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Jay"
android:layout_marginLeft="10dp"
android:textSize="15dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="19"
android:layout_marginLeft="10dp"
android:textSize="15dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9363271917"
android:layout_marginLeft="10dp"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Kolhapur"
android:layout_marginLeft="10dp"
android:textSize="15dp" />
</TableRow>
</TableLayout>

Output

Practical No:
Mobile Application Development

2.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FA8072"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00FFFF"
android:text="DataTypes in Object Oriented Programming"
android:gravity="center"
android:layout_marginTop="100dp"
android:textStyle="italic"
android:textSize="20dp"
android:textColor="#000000"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Integer"
android:gravity="center"
android:background="#EE82EE"
android:layout_marginTop="200dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:textColor="#000000"
android:textSize="20dp"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Character"
android:background="#FF69B4"
android:textColor="#000000"
android:gravity="center"

Practical No:
Mobile Application Development

android:layout_marginTop="300dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:textSize="20dp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Boolean"
android:background="#F4A460"
android:textColor="#000000"
android:gravity="center"
android:layout_marginTop="400dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:textSize="20dp"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Float"
android:textColor="#000000"
android:gravity="center"
android:layout_marginTop="500dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:textSize="20dp"
android:background="#FF6347"/>

</FrameLayout>

Output

Practical No:
Mobile Application Development

Practical No:
Mobile Application Development

X. Exercise

Practical No: 7
1. <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF7F50"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text1"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:text="LOGIN"
android:layout_marginTop="14dp"
android:textAppearance="?android:attr/textAppearanceLarge"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:layout_below="@id/text1"
android:layout_marginTop="70dp"
android:text="Username"
android:textAppearance="?android:attr/textAppearanceLarge"/>

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/t2editText1"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/textView1"
android:layout_toRightOf="@+id/textView1"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:layout_below="@id/textView1"
android:layout_marginTop="60dp"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceLarge"/>
Practical No:
Mobile Application Development

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/textView2"
android:layout_toRightOf="@id/textView2"
android:inputType="textPassword"/>

<Button
android:layout_width="wrap_content"

Practical No:
Mobile Application Development

android:layout_height="wrap_content"
android:id="@+id/btnSubmit"
android:layout_alignParentLeft="false"
android:layout_below="@id/editText2"
android:layout_centerInParent="true"
android:layout_marginTop="60dp"
android:text="Submit"/>

Output

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF7F50"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text1"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:text="LOGIN"
android:layout_marginTop="14dp"
android:textAppearance="?android:attr/textAppearanceLarge"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:layout_below="@id/text1"
android:layout_marginTop="70dp"
Practical No:
Mobile Application Development

android:text="Username"
android:textAppearance="?android:attr/textAppearanceLarge"/>

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/t2editText1"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/textView1"
android:layout_toRightOf="@+id/textView1"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:layout_below="@id/textView1"
android:layout_marginTop="60dp"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceLarge"/>

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/textView2"
android:layout_toRightOf="@id/textView2"
android:inputType="textPassword"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnSubmit"
android:layout_alignParentLeft="false"
android:layout_below="@id/editText2"
android:layout_centerInParent="true"
android:layout_marginTop="60dp"
android:text="Submit"/>

Output

Practical No:
Mobile Application Development

Practical No:
Mobile Application Development

Practical No: 8
X. Exercise
1. <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="#E5E4E2"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yahoo!"
android:textSize="60dp"
android:textColor="#400090"
android:gravity="center"
android:layout_marginTop="100dp"
android:layout_marginLeft="100dp"
android:textStyle="italic" />

<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="300dp"
android:hint="Enter Text"
android:padding="15dp"
android:textColorHint="#000000"
android:textStyle="italic"
android:id="@+id/au1"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />

</RelativeLayout>

Output

Practical No:
Mobile Application Development

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CCEEFF"
tools:context=".MainActivity">

<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="300dp"
android:hint="Enter Text"
android:padding="15dp"
android:textColorHint="#000000"
android:textStyle="italic"
android:id="@+id/au1"
android:gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>

</RelativeLayout>

Output

Practical No:
Mobile Application Development

Practical No: 9
1. <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="150dp"
android:orientation="horizontal">

<ToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tb1"
android:layout_gravity="center_horizontal"
android:checked="false"
android:drawablePadding="20dp"
android:textColor="#000"/>

<ToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tb2"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="50dp"
android:checked="true"
android:drawablePadding="20dp"
android:textColor="#000" />

</LinearLayout>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/b1"
android:layout_gravity="center"
android:background="#0f0"
android:padding="10dp"
Practical No:
Mobile Application Development

android:text="Submit"
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginTop="150dp"/>

</LinearLayout>

Output

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relative1"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:id="@+id/edt1" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_alignEnd="@+id/button4"
android:layout_alignRight="@+id/button4"
android:layout_below="@+id/edt1"
android:layout_marginTop="94dp"
android:text="1"/>

Practical No:
Mobile Application Development

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_alignTop="@+id/button1"
android:layout_toLeftOf="@+id/button3"
android:layout_toStartOf="@+id/button3"
android:text="2" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_alignTop="@+id/button2"
android:layout_centerHorizontal="true"
android:text="3"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button4"
style="?android:attr/buttonStyleSmall"
android:layout_below="@id/button1"
android:layout_toLeftOf="@+id/button2"
android:text="4"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button5"
style="?android:attr/buttonStyleSmall"
android:layout_alignBottom="@+id/button4"
android:layout_alignStart="@id/button2"
android:layout_alignLeft="@+id/button2"
android:text="5"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button6"
style="?android:attr/buttonStyleSmall"
android:layout_alignLeft="@+id/button3"
android:layout_alignStart="@+id/button3"
android:layout_below="@id/button3"
android:text="6" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"

Practical No:
Mobile Application Development

android:id="@+id/button7"
style="?android:attr/buttonStyleSmall"
android:layout_toLeftOf="@+id/button2"
android:layout_below="@+id/button4"
android:text="7" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button8"
style="?android:attr/buttonStyleSmall"
android:layout_alignLeft="@+id/button5"
android:layout_alignStart="@id/button5"
android:layout_below="@id/button5"
android:text="8" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button9"
style="?android:attr/buttonStyleSmall"
android:layout_alignStart="@id/button6"
android:layout_alignLeft="@id/button6"
android:layout_below="@+id/button6"
android:text="9"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonadd"
style="?android:attr/buttonStyleSmall"
android:layout_alignEnd="@+id/edt1"
android:layout_alignRight="@+id/edt1"
android:layout_alignTop="@+id/button3"
android:layout_marginLeft="46dp"
android:layout_marginStart="46dp"
android:layout_toRightOf="@+id/button3"
android:text="+" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonsub"
style="?android:attr/buttonStyleSmall"
android:layout_alignEnd="@+id/buttonadd"
android:layout_alignLeft="@+id/buttonadd"
android:layout_alignRight="@+id/buttonadd"
android:layout_alignStart="@+id/buttonadd"
android:layout_below="@+id/buttonadd"
android:text="-"/>

<Button

Practical No:
Mobile Application Development

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonmul"
style="?android:attr/buttonStyleSmall"
android:layout_alignLeft="@+id/buttonsub"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignStart="@+id/buttonsub"
android:layout_marginRight="40dp"
android:text="*"
android:layout_below="@+id/buttonsub" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button10"
style="?android:attr/buttonStyleSmall"
android:layout_below="@id/button7"
android:layout_toLeftOf="@+id/button2"
android:text="." />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button0"
style="?android:attr/buttonStyleSmall"
android:layout_alignLeft="@id/button8"
android:layout_alignStart="@id/button8"
android:layout_below="@+id/button8"
android:text="0" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonC"
style="?android:attr/buttonStyleSmall"
android:layout_alignLeft="@id/button9"
android:layout_alignStart="@id/button9"
android:layout_below="@+id/button9"
android:text="C" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttondiv"
style="?android:attr/buttonStyleSmall"
android:layout_alignEnd="@id/buttonmul"
android:layout_alignRight="@id/buttonmul"
android:layout_alignLeft="@id/buttonmul"
android:layout_alignStart="@id/buttonmul"
android:layout_below="@id/buttonmul"
android:text="/" />

Practical No:
Mobile Application Development

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttoneql"
style="?android:attr/buttonStyleSmall"
android:layout_alignEnd="@id/buttondiv"
android:layout_alignLeft="@id/button10"
android:layout_alignRight="@id/buttondiv"
android:layout_alignStart="@id/button10"
android:layout_below="@+id/button0"
android:layout_marginTop="37dp"
android:text="=" />

</RelativeLayout>

Output

Practical No:
Mobile Application Development

Practical No: 10
X. Exercise
1. <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Facebook"
android:gravity="center"
android:textSize="40dp"
android:textColor="#FFF"
android:background="#0000FF"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter Username"
android:gravity="center"
android:layout_marginTop="120dp"
android:layout_marginRight="40dp"
android:layout_marginLeft="40dp />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter Password"
android:gravity="center"
android:layout_marginTop="40dp"
android:layout_marginRight="40dp"
android:layout_marginLeft="40dp" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:text="LOGIN"
android:textSize="30sp"
android:textStyle="italic"/>

<TextView

Practical No:
Mobile Application Development

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't have account?SignUp"
android:textColor="#000000"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="50dp"/>

</LinearLayout>

Output

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


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#CCEEFF"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter Username"
android:gravity="center"
android:layout_marginTop="120dp"
android:layout_marginRight="40dp"
android:layout_marginLeft="40dp" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter Password"
android:gravity="center"
android:layout_marginTop="40dp"
Practical No:
Mobile Application Development

android:layout_marginRight="40dp"
android:layout_marginLeft="40dp" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:text="LOGIN"
android:textSize="30sp"
android:textStyle="italic"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't have account?Register"
android:textColor="#000000"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="50dp"/>

</LinearLayout>

Output

Practical No:
Mobile Application Development

Practical No: 11
1. .xml file

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


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<CheckBox
android:id="@+id/cb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pizza"
android:gravity="center"
android:textSize="20sp"
android:layout_marginLeft="150dp"
android:layout_marginTop="150dp"/>

<CheckBox
android:id="@+id/cb2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Burger"
android:gravity="center"
android:layout_marginLeft="150dp"
android:layout_marginTop="50dp"
android:textSize="20sp" />

<CheckBox
android:id="@+id/cb3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Coffee"
android:textSize="20sp"
android:gravity="center"
android:layout_marginLeft="150dp"
android:layout_marginTop="50dp" />

<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Submit"
android:layout_marginTop="70dp"
Practical No:
Mobile Application Development

android:textSize="30sp"
android:textColor="#000000"/>

</LinearLayout>

.java file
package com.example.p11_1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


CheckBox pizza,burger,coffee;
Button bu1;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pizza=findViewById(R.id.cb1);
burger=findViewById(R.id.cb2);
coffee=findViewById(R.id.cb3);
bu1=findViewById(R.id.b1);
bu1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StringBuffer res=new StringBuffer();
int sum=0;
res.append("Selected Item:-"+"\n");
if(pizza.isChecked())
{
res.append("Pizza Rs.100" +"\n");
sum=sum+100;

}
if (burger.isChecked())
{
res.append("Burger Rs.200"+"\n");
sum=sum+200;

}
if (coffee.isChecked())
{
res.append("Coffee Rs.300"+"\n");
sum=sum+300;

}
Practical No:
Mobile Application Development

res.append("Total amount"+"\n"+sum+"Rs");
Toast.makeText(MainActivity.this, res.toString(), Toast.LENGTH_LONG).show();
}
});

}
}

Output

Practical No:
Mobile Application Development

Practical No: 12
1. <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Single Radio Buttons"
android:gravity="center"
android:id="@+id/text1"
android:layout_marginTop="40dp"
android:textSize="20dp"/>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Radio Button 1"
android:layout_marginTop="70dp"
android:id="@+id/rb1"/>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Radio Button 2"
android:layout_marginTop="20dp"
android:id="@+id/rb2"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/text2"
android:paddingLeft="50dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="Radio button inside RadioGroup"
android:textSize="20dp" />

<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:id="@+id/rg1">
Practical No:
Mobile Application Development

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:layout_marginTop="20dp"
android:id="@+id/rb3"/>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:layout_marginTop="20dp"
android:id="@+id/rb4"/>
</RadioGroup>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show selected"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginTop="40dp"
android:textSize="20dp"
android:id="@+id/button1"/>

</LinearLayout>

Output

Practical No:

You might also like