Ad Code

Responsive Advertisement

Basic Android Program 02

Question 02: Write a program to display student name and marks.

Download hole Program / Project code, by clicking following link:

List the files used to write hello world program in android studio?

To write a "Hello World" program in Android Studio, the following files are typically used:
  • MainActivity.java: This is the main Java file that contains the code for the "Hello World" program. It defines the behavior of the main activity of the application.

  • activity_main.xml: This is an XML layout file that defines the user interface of the main activity. It specifies the views that will be displayed on the screen, such as text views, buttons, and images.

  • AndroidManifest.xml: This is an XML file that describes the components of the application and their properties. It contains information such as the application package name, the activities in the application, and the permissions required by the application.

  • build.gradle: This is a Gradle build script that specifies the dependencies and configurations of the application. It defines the versions of the Android SDK, support libraries, and other dependencies required by the application.
These files work together to create a "Hello World" program in Android Studio. The MainActivity.java file contains the Java code that displays the "Hello World" message on the screen, while the activity_main.xml file defines the layout of the user interface. The AndroidManifest.xml file provides information about the application, and the build.gradle file specifies the dependencies and configurations of the application.


Programming Code:

Following code write in: MainActivity.java
package com.go2collage.practical_02;

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

Following code write in: activity_main.java
<?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"
tools:context=".MainActivity"
android:layout_margin="20dp"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="go2collage"
android:textSize="32sp"
android:textStyle="bold"
android:textAlignment="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
tools:ignore="HardcodedText" />

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

<TextView
android:layout_width="280sp"
android:layout_height="wrap_content"
android:text="Name"
android:textStyle="bold"
android:textSize="18sp"
android:textColor="@color/black"
tools:ignore="HardcodedText" />

<TextView
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="Marks"
android:textStyle="bold"
android:textColor="@color/black"
tools:ignore="HardcodedText" />
</LinearLayout>

<!-- Student 1-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
>

<TextView
android:layout_width="280sp"
android:layout_height="wrap_content"
android:text="Raju"
android:textSize="18sp"
android:textColor="@color/black"
tools:ignore="HardcodedText" />

<TextView
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="80%"
android:textColor="@color/black"
tools:ignore="HardcodedText" />
</LinearLayout>

<!-- Student 2-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
>

<TextView
android:layout_width="280sp"
android:layout_height="wrap_content"
android:text="Sonu"
android:textSize="18sp"
android:textColor="@color/black"
tools:ignore="HardcodedText" />

<TextView
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="92%"
android:textColor="@color/black"
tools:ignore="HardcodedText" />
</LinearLayout>

<!-- Student 3-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
>

<TextView
android:layout_width="280sp"
android:layout_height="wrap_content"
android:text="Pinky"
android:textSize="18sp"
android:textColor="@color/black"
tools:ignore="HardcodedText" />

<TextView
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="88%"
android:textColor="@color/black"
tools:ignore="HardcodedText" />
</LinearLayout>

<!-- Student 4-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
>

<TextView
android:layout_width="280sp"
android:layout_height="wrap_content"
android:text="Abdul"
android:textSize="18sp"
android:textColor="@color/black"
tools:ignore="HardcodedText" />

<TextView
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="89%"
android:textColor="@color/black"
tools:ignore="HardcodedText" />
</LinearLayout>

<!-- Student 5-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
>

<TextView
android:layout_width="280sp"
android:layout_height="wrap_content"
android:text="Lalu"
android:textSize="18sp"
android:textColor="@color/black"
tools:ignore="HardcodedText" />

<TextView
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="60%"
android:textColor="@color/black"
tools:ignore="HardcodedText" />
</LinearLayout>




</LinearLayout>

Output:




Post a Comment

0 Comments

Ad Code

Responsive Advertisement