EXP 8 LIBRARY MANAGEMENT SYSTEM
🎯 AIM
To develop a Library Management System using Android Studio that allows users to enter
book details, validates the inputs on the frontend, and displays a cute success message upon
submission. The app uses a beautiful UI and ensures input correctness without connecting to
a backend.
� ALGORITHM
1. Start the Application.
2. Display the book entry form with fields:
Book Name, Author, ISBN, and Category.
3. Wait for the user to enter the details.
4. On Submit Button Click:
o Check if all fields are filled.
o If any field is empty, show a toast message: “Please fill all fields”.
o If all fields are valid:
Display a big “Book Added Successfully” message.
5. End.
💻 CODE STRUCTURE
✅ MainActivity.kt
kotlin
CopyEdit
package com.example.calci
import android.os.Bundle
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val bookName = findViewById<EditText>(R.id.bookName)
val author = findViewById<EditText>(R.id.author)
val isbn = findViewById<EditText>(R.id.isbn)
val category = findViewById<EditText>(R.id.category)
val submitBtn = findViewById<Button>(R.id.submitBtn)
val message = findViewById<TextView>(R.id.successMessage)
submitBtn.setOnClickListener {
val bName = bookName.text.toString().trim()
val auth = author.text.toString().trim()
val isbnCode = isbn.text.toString().trim()
val cat = category.text.toString().trim()
if (bName.isEmpty() || auth.isEmpty() || isbnCode.isEmpty() ||
cat.isEmpty()) {
Toast.makeText(this, "Please fill all fields",
Toast.LENGTH_SHORT).show()
} else {
message.text = "\uD83D\uDCDA Book Added Successfully!"
message.visibility = TextView.VISIBLE
}
}
}
}
� activity_main.xml
xml
CopyEdit
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="24dp"
android:gravity="center"
android:background="@color/pink_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="📖 Library Book Entry"
android:textSize="26sp"
android:textColor="@color/deep_pink"
android:layout_marginBottom="24dp"
android:textStyle="bold"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/bookName"
android:hint="Book Name"
android:background="@drawable/input_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/author"
android:hint="Author Name"
android:background="@drawable/input_bg"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/isbn"
android:hint="ISBN"
android:background="@drawable/input_bg"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/category"
android:hint="Category"
android:background="@drawable/input_bg"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/submitBtn"
android:text="Submit"
android:layout_marginTop="16dp"
android:backgroundTint="@color/deep_pink"
android:textColor="#fff"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/successMessage"
android:text=""
android:textSize="22sp"
android:gravity="center"
android:textStyle="bold"
android:textColor="@color/success_green"
android:layout_marginTop="18dp"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
🎨 colors.xml
xml
CopyEdit
<resources>
<color name="pink_bg">#FFF0F5</color>
<color name="deep_pink">#FF1493</color>
<color name="success_green">#228B22</color>
</resources>
🎨 input_bg.xml (drawable folder)
xml
CopyEdit
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners android:radius="16dp"/>
<stroke android:width="2dp" android:color="#FFB6C1"/>
<padding android:left="12dp" android:right="12dp"/>
</shape>
OUTPUT:
✅ RESULT
When the user fills in all the fields and presses Submit, the screen displays:
📚 Book Added Successfully!
With cute pink background, rounded input fields, toast messages for empty fields, and
success UI.