0% found this document useful (0 votes)
50 views4 pages

Mad PR 6

The document describes two exercises for displaying data using Android layouts. The first uses a TableLayout to display basic information for 10 students in a table. The second uses a FrameLayout to display common data types like Integer, String, Float, and Char with TextViews arranged vertically.

Uploaded by

tech news
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)
50 views4 pages

Mad PR 6

The document describes two exercises for displaying data using Android layouts. The first uses a TableLayout to display basic information for 10 students in a table. The second uses a FrameLayout to display common data types like Integer, String, Float, and Char with TextViews arranged vertically.

Uploaded by

tech news
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/ 4

X.

Exercise:
1) Write a program to display 10 students basic information in a table form using Table
layout
activity_main.xml
<?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"
tools:context=".MainActivity">

<TableRow
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/gray">
<TextView
android:layout_width="150dp"
android:text="Sr. No" />
<TextView
android:layout_width="150dp"
android:text="Name"/>
<TextView
android:layout_width="150dp"
android:text="Enrollment"/>
</TableRow>

<TableRow>
<TextView android:text="1" />
<TextView android:text="Shaikh Ibrahim" />
<TextView android:text="2005690140" />
</TableRow>

<TableRow>
<TextView android:text="2" />
<TextView android:text="Gulamnabi" />
<TextView android:text="2005690172" />
</TableRow>

<TableRow>
<TextView android:text="3" />
<TextView android:text="Shaikh Asil" />
<TextView android:text="2005690168" />
</TableRow>

<TableRow>
<TextView android:text="4" />
<TextView android:text="Shaikh Raza" />
<TextView android:text="2005690127" />
</TableRow>

<TableRow>
<TextView android:text="5" />
<TextView android:text="Khan Ayan" />
<TextView android:text="2005690141" />
</TableRow>

<TableRow>
<TextView android:text="6" />
<TextView android:text="Gouri" />
<TextView android:text="2005690161" />
</TableRow>

<TableRow>
<TextView android:text="7" />
<TextView android:text="Ali" />
<TextView android:text="2005690165" />
</TableRow>

<TableRow>
<TextView android:text="8" />
<TextView android:text="Abbas" />
<TextView android:text="2005690173" />
</TableRow>

<TableRow>
<TextView android:text="9" />
<TextView android:text="Zaid" />
<TextView android:text="2005690166" />
</TableRow>

<TableRow>
<TextView android:text="10" />
<TextView android:text="Umair" />
<TextView android:text="2005690160" />
</TableRow>
</TableLayout>

MainActivity.java
package com.example.linear_layout;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Output (On Android Emulator):


2) Write a program to display all the data types in object-oriented programming using Frame
layout
activity_main.xml
<?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="wrap_content"
tools:context=".MainActivity"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Integer"
android:textSize="20dp"
android:textAlignment="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="String"
android:textSize="20dp"
android:textAlignment="center"
android:layout_marginTop="30dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Float"
android:textSize="20dp"
android:textAlignment="center"
android:layout_marginTop="60dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Char"
android:textSize="20dp"
android:textAlignment="center"
android:layout_marginTop="90dp"/>
</FrameLayout>

MainActivity.java
package com.example.linear_layout;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Output (On Android Emulator):

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy