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
- Open Android Studio
- Click on “New Project”
- Choose Empty Activity
- Name it: StudentDetailsApp
- Language: Java
- Click Finish
πΌ Step 2: Design the Layout (XML)
Go to res/layout/activity_main.xml and replace the default content with the following:
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
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:This project is a solid foundation for learning how to handle data, build user interfaces, and understand Android lifecycle basics.
- Uses a layout with TextView elements
- Assigns and displays static student data in Java
- Runs on a real or virtual Android device
Comments
Post a Comment