0% found this document useful (0 votes)
31 views3 pages

Practical 7

1. The document describes a program that accepts username and password from the user using text views and edit texts in an Android app. It includes XML code to define the layout containing these elements. 2. The program accepts and displays personal information of a student, including name, roll number. The XML code defines a table layout containing text views and edit texts to collect this information. 3. The Java code imports necessary classes and defines a basic activity class to handle displaying the layout defined in XML.

Uploaded by

Om Dewoolkar
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)
31 views3 pages

Practical 7

1. The document describes a program that accepts username and password from the user using text views and edit texts in an Android app. It includes XML code to define the layout containing these elements. 2. The program accepts and displays personal information of a student, including name, roll number. The XML code defines a table layout containing text views and edit texts to collect this information. 3. The Java code imports necessary classes and defines a basic activity class to handle displaying the layout defined in XML.

Uploaded by

Om Dewoolkar
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/ 3

1.

Write a program to accept username and android:layout_height="48dp"


android:layout_marginStart="17dp"
password from the end user using Text
android:ems="10" android:hint="enter
View and Edit Text. your username"
android:inputType="text"
app:layout_constraintBottom_toBottomOf=
"parent"
XML code: app:layout_constraintEnd_toEndOf="parent
"
<?xml version="1.0" encoding="utf-8"?> app:layout_constraintHorizontal_bias="0.0"
<androidx.constraintlayout.widget.ConstraintLayout app:layout_constraintStart_toEndOf="@+id
xmlns:android="http://schemas.android.com/apk/res/android" /textView"
xmlns:app="http://schemas.android.com/apk/res-auto" app:layout_constraintTop_toTopOf="parent
xmlns:tools="http://schemas.android.com/tools" "
android:layout_width="match_parent" app:layout_constraintVertical_bias="0.128" />
android:layout_height="match_parent"
tools:context=".MainActivity"> <Button android:id="@+id/button"
android:layout_width="wrap_content"
<EditText android:id="@+id/editTextText" android:layout_height="wrap_content"
android:layout_width="203dp" android:text="Submit"
android:layout_height="48dp" app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="19dp" app:layout_constraintEnd_toEndOf="parent"
android:ems="10" android:hint="enter your app:layout_constraintHorizontal_bias="0.286"
password" android:inputType="textPassword" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintVertical_bias="0.445" />
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/textView3" <Button android:id="@+id/button2"
app:layout_constraintTop_toTopOf="parent" android:layout_width="wrap_content"
app:layout_constraintVertical_bias="0.234" /> android:layout_height="wrap_content"
android:text="Cancel"
<TextView android:id="@+id/textView" app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content" app:layout_constraintEnd_toEndOf="parent"
android:layout_height="wrap_content" app:layout_constraintHorizontal_bias="0.677"
android:text="Username:" app:layout_constraintStart_toStartOf="parent"
android:textSize="20sp" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintVertical_bias="0.445" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.13" </androidx.constraintlayout.widget.ConstraintLayout>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.14" />

<TextView Java Code:


android:id="@+id/textView3"
android:layout_width="wrap_content" package com.example.pratical7;
android:layout_height="wrap_content"
android:text="Password:" import androidx.appcompat.app.AppCompatActivity;
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent" import android.os.Bundle;
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.129"
public class MainActivity extends AppCompatActivity {
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.076" /> @Override
protected void onCreate(Bundle savedInstanceState) {
<EditText super.onCreate(savedInstanceState);
android:id="@+id/editTextText" setContentView(R.layout.activity_main);
android:layout_width="203dp" }}
Output: app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.254">

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingBottom="10dp">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name:"
android:textSize="30sp" />

<EditText
android:id="@+id/editTextText"
android:layout_width="252dp"
android:layout_height="wrap_content"
2. Write a program to accept and display android:ems="10" android:hint="Enter
your name" android:inputType="text"
personal information of the student. android:textSize="24sp" />
</TableRow>
XML code:
<TableRow
<?xml version="1.0" encoding="utf-8"?> android:layout_width="match_parent"
<androidx.constraintlayout.widget.ConstraintLayout android:layout_height="106dp"
xmlns:android="http://schemas.android.com/apk/res/android" android:paddingLeft="10sp"
xmlns:app="http://schemas.android.com/apk/res-auto" android:paddingBottom="10dp">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
<TextView
android:layout_height="match_parent"
android:id="@+id/textView"
tools:context=".MainActivity">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<TextView android:text="Roll No:"
android:layout_width="wrap_content" android:textSize="30sp" />
android:layout_height="wrap_content"
android:text="Student Information"
<EditText
android:textSize="24sp"
android:id="@+id/editTextText"
android:layout_width="252dp"
app:layout_constraintBottom_toTopOf="@+id/tableLayout" android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent" android:ems="10" android:hint="Enter
app:layout_constraintHorizontal_bias="0.497" your roll no"
app:layout_constraintStart_toStartOf="parent" android:inputType="number"
app:layout_constraintTop_toTopOf="parent" android:textSize="24sp" />
app:layout_constraintVertical_bias="0.391" /> </TableRow>

<TableLayout android:id="@+id/tableLayout" <TableRow


android:layout_width="408dp" android:layout_width="match_parent"
android:layout_height="267dp" android:layout_height="match_parent"
android:paddingLeft="10dp" }
android:paddingBottom="10dp">
}
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
Output:
android:layout_height="wrap_content"

android:text="Class:"
android:textSize="30sp" />

<EditText
android:id="@+id/editTextText"
android:layout_width="252dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter your class"
android:inputType="text"
android:textSize="24sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="61dp"
android:paddingLeft="10dp">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enno:"
android:textSize="30sp" />
<EditText
android:id="@+id/editTextText"
android:layout_width="252dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter your
enrollment no"
android:inputType="number"
android:textSize="24sp" />
</TableRow>
</TableLayout>
</androidx.constraintlayout.widget.Constraint
Layout>
Java code:
package com.example.practical7_2;
import
androidx.appcompat.app.AppCompatActivit;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

You might also like