Build a Simple Android App to Display Student Details

Build a Simple Android App to Display Student Details (Student Details App)

In this tutorial, we’ll walk through the steps to create a basic Android application that displays a student’s details such as name, and marks. This is a great starting project for Android development using Java.

πŸ›  What You’ll Learn

  • Creating a new Android Studio project
  • Designing a layout with TextViews
  • Writing Java code to display student data
  • Running the app on an emulator or physical device

πŸ“¦ Step 1: Create a New Project

  1. Open Android Studio
  2. Click on “New Project”
  3. Choose Empty Activity
  4. Name it: StudentDetailsApp
  5. Language: Java
  6. Click Finish

πŸ–Ό Step 2: Design the Layout (XML)

Go to res/layout/activity_main.xml and replace the default content with the following:

activity_main.xml

<?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:padding="10dp"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/nameText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Student name: Amol Chaudhari"
        android:textSize="24sp" />

    <TextView
        android:id="@+id/marksText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Marks: 75.00"
        android:textSize="24sp" />
</LinearLayout> 

🧠 Step 3: Add Java Code

Open MainActivity.java and update the code as follows:

MainActivity.java

package com.example.studentdetailsapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
    TextView nameText, marksText;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        nameText = findViewById(R.id.nameText);
        marksText = findViewById(R.id.marksText);
        
        // Sample student data
        String name = "Amol Chaudhari";
        String marks = "75.00";
        
        // Set data to TextViews
        nameText.setText("Studet name: " + name);
        marksText.setText("Marks: " + marks);
    }
}

▶️ Step 4: Run the App

Click the Run ▶️ button in Android Studio. Choose your emulator or connected Android device. The app will launch and display student details on the screen.
πŸ“± OUTPUT

πŸ“Œ Optional Enhancements

  • Add an image of the student using ImageView
  • Use EditText fields to allow user input
  • Display multiple students using a RecyclerView

✅ Summary

You’ve just built a simple Android app that:
  • Uses a layout with TextView elements
  • Assigns and displays static student data in Java
  • Runs on a real or virtual Android device
This project is a solid foundation for learning how to handle data, build user interfaces, and understand Android lifecycle basics.

Comments

Popular posts from this blog

Develop an Android application to display “Hello World!” on screen

Program to design an applet which draws a circle (having color BLUE) inside a triangle (having color YELLOW)