0% found this document useful (1 vote)
718 views4 pages

Practical No: 04 Exercise: 1. Write A Program To Display Helloworld

The document describes two Android programs - one to display the text "Hello World!" and another to display fields for a student's name and marks. The first program includes an XML layout file with a TextView to display the text. The Java code sets this layout on the activity. The second program has an XML layout with two EditText fields, one for the student's name and another for their marks. The Java code again just sets this layout on the activity.

Uploaded by

Ss1122
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 (1 vote)
718 views4 pages

Practical No: 04 Exercise: 1. Write A Program To Display Helloworld

The document describes two Android programs - one to display the text "Hello World!" and another to display fields for a student's name and marks. The first program includes an XML layout file with a TextView to display the text. The Java code sets this layout on the activity. The second program has an XML layout with two EditText fields, one for the student's name and another for their marks. The Java code again just sets this layout on the activity.

Uploaded by

Ss1122
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/ 4

Darshan Mahale

1905300023

Practical No: 04
Exercise
1. Write a program to display HelloWorld

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

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="40dp"
android:textStyle="italic"
android:textColor="@color/purple_500"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java:
package com.example.helloworld;

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);
Darshan Mahale
1905300023

}
}
OUTPUT:
Darshan Mahale
1905300023

2. Write a program to display student name and marks.


Activity_Main.xml:

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


<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:id="@+id/editTextTextPersonName"
android:layout_width="353dp"
android:layout_height="143dp"
android:ems="10"
android:inputType="textPersonName"
android:text="student name"
android:textSize="40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.349"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.256" />

<EditText
android:id="@+id/editTextTextPersonName2"
android:layout_width="344dp"
android:layout_height="136dp"
android:ems="10"
android:inputType="textPersonName"
android:text="marks"
android:textSize="40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.297"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.557" />

</androidx.constraintlayout.widget.ConstraintLayout>
Darshan Mahale
1905300023

MainActivity.java:

package com.example.practical4ex;

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);
}
}

You might also like