Simple Admin Panel

 First Create res->values->arrays.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="class_options">
<item>Class 1</item>
<item>Class 2</item>
<item>Class 3</item>
<!-- Add more class options as needed -->
</string-array>
</resources>

Write XML code below here

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">

<!-- Toolbar -->
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:title="Student Admin Panel"
android:titleTextColor="@android:color/white" />

<!-- Content Container -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:orientation="vertical"
android:padding="16dp">

<!-- Student Information Form -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="16dp">

<EditText
android:id="@+id/editTextStudentName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Student Name" />

<EditText
android:id="@+id/editTextRollNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Roll Number" />

<Spinner
android:id="@+id/spinnerClass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Select Class"
android:entries="@array/class_options" />

<!-- Add more fields as needed -->

<Button
android:id="@+id/btnAddStudent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Student" />

</LinearLayout>

<!-- Student List -->
<ListView
android:id="@+id/listViewStudents"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="16dp" />

</LinearLayout>

</RelativeLayout>

Write Java Code below here

package com.example.superadminpanel;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

private EditText editTextStudentName, editTextRollNumber;
private Spinner spinnerClass;
private Button btnAddStudent;
private ListView listViewStudents;

private List<String> studentList;
private ArrayAdapter<String> adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Initialize UI elements
editTextStudentName = findViewById(R.id.editTextStudentName);
editTextRollNumber = findViewById(R.id.editTextRollNumber);
spinnerClass = findViewById(R.id.spinnerClass);
btnAddStudent = findViewById(R.id.btnAddStudent);
listViewStudents = findViewById(R.id.listViewStudents);

// Initialize student list
studentList = new ArrayList<>();
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, studentList);
listViewStudents.setAdapter(adapter);

// Set up the class options in the Spinner
ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(
this,
R.array.class_options,
android.R.layout.simple_spinner_item
);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerClass.setAdapter(spinnerAdapter);

// Handle button click to add a student
btnAddStudent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addStudent();
}
});

// Handle item selection in the Spinner
spinnerClass.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
String selectedClass = adapterView.getItemAtPosition(position).toString();
// Handle class selection if needed
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {
// Do nothing
}
});
}

private void addStudent() {
String studentName = editTextStudentName.getText().toString().trim();
String rollNumber = editTextRollNumber.getText().toString().trim();
String selectedClass = spinnerClass.getSelectedItem().toString();

if (!studentName.isEmpty() && !rollNumber.isEmpty()) {
String studentInfo = "Name: " + studentName + "\nRoll Number: " + rollNumber + "\nClass: " + selectedClass;
studentList.add(studentInfo);
adapter.notifyDataSetChanged();

// Clear input fields
editTextStudentName.setText("");
editTextRollNumber.setText("");

Toast.makeText(this, "Student added successfully", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Please fill out all fields", Toast.LENGTH_SHORT).show();
}
}
}


Now Create a Admin Panel, WOW


Complete UI design Admin panel 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#fdf9f8"
tools:context=".MainActivity">

<androidx.cardview.widget.CardView
android:id="@+id/topBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:elevation="10dp"
app:cardBackgroundColor="#fdf9f8">
<LinearLayout

android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textColor="#CEA66A"
android:textSize="20sp"
android:text="Super Admin Panel"
android:gravity="center_vertical"
android:padding="10dp"
android:textStyle="bold"
android:layout_weight="2"/>

<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="fill_parent"
android:layout_height="match_parent"
app:menu="@menu/top_menu"
app:compatShadowEnabled="false"
android:background="#fdf9f8"
android:layout_weight="5"/>
</LinearLayout>

</androidx.cardview.widget.CardView>



<LinearLayout
android:id="@+id/latestNotification"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/background"
android:orientation="horizontal"
android:layout_margin="10dp"
android:layout_below="@+id/topBar">

</LinearLayout>

<androidx.cardview.widget.CardView
android:id="@+id/insertBox"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_below="@+id/latestNotification"
app:cardCornerRadius="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:elevation="15dp"
app:cardBackgroundColor="#fdf9f8"
>


<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="40dp"
android:hint="Your Name"
app:endIconMode="clear_text"
app:counterEnabled="true"
app:counterMaxLength="20"
app:startIconDrawable="@drawable/person"
app:startIconTint="#CEA66A"
app:boxStrokeWidth="2dp"
android:keyboardNavigationCluster="true"
app:boxStrokeErrorColor="#FB1C00"
app:boxStrokeColor="#CEA66A"
app:iconTint="#FF0D82FF"
android:layout_height="wrap_content">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/Name"
android:layout_width="match_parent"
android:layout_height="60dp"
android:padding="10dp"
android:textSize="20sp"
android:inputType="textPersonName"
android:textColor="@color/black"
android:maxLength="20" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:hint="Your Email"
app:endIconMode="clear_text"
app:counterEnabled="true"
app:counterMaxLength="30"
app:startIconDrawable="@drawable/baseline_email_24"
app:startIconTint="#CEA66A"
app:boxStrokeWidth="2dp"
app:boxStrokeErrorColor="#FB1C00"
app:boxStrokeColor="#CEA66A"
app:iconTint="#FF0D82FF"
android:layout_height="wrap_content">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="60dp"
android:padding="10dp"
android:textSize="20sp"
android:inputType="textEmailAddress"
android:textColor="@color/black"
android:maxLength="30" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:hint="Your Mobile"
app:endIconMode="clear_text"
app:counterEnabled="true"
app:boxStrokeWidth="2dp"
app:boxStrokeErrorColor="#FB1C00"
app:counterMaxLength="11"
android:preferKeepClear="true"
app:startIconDrawable="@drawable/baseline_add_ic_call_24"
app:startIconTint="#CEA66A"
app:boxStrokeColor="#CEA66A"
app:iconTint="#0D82FF"
android:layout_height="wrap_content">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/mobile"
android:layout_width="match_parent"
android:layout_height="60dp"
android:padding="5dp"
android:gravity="center_vertical"
android:textSize="20sp"
android:inputType="number"
android:textColor="@color/black"
android:maxLength="11" />
</com.google.android.material.textfield.TextInputLayout>


<androidx.appcompat.widget.AppCompatButton
android:id="@+id/insertBtn"
android:layout_width="200dp"
android:layout_height="60dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/ed_style"
android:textColor="@color/white"
android:textSize="16sp"
android:text="Insert Your data"
/>

</LinearLayout>


</androidx.cardview.widget.CardView>


<LinearLayout
android:id="@+id/itemBottom"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_below="@+id/insertBox"
android:layout_margin="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:background="@drawable/background"
android:orientation="vertical">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:src="@drawable/img"/>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Update"
android:gravity="center"
android:textSize="18sp"
android:layout_marginTop="-10dp"/>
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:background="@drawable/background"
android:orientation="vertical">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:src="@drawable/img"/>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Update"
android:gravity="center"
android:textSize="18sp"
android:layout_marginTop="-10dp"/>
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:background="@drawable/background"
android:orientation="vertical">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:src="@drawable/img"/>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Update"
android:gravity="center"
android:textSize="18sp"
android:layout_marginTop="-10dp"/>
</LinearLayout>

</LinearLayout>

<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="60dp"
app:menu="@menu/bottom_menu"
android:layout_alignParentBottom="true"/>

</RelativeLayout>




Post a Comment

Post a Comment (0)

Previous Post Next Post