Q1: UI Layout For The Main Attendance Screen
Q1: UI Layout For The Main Attendance Screen
UI Components:
TextView: Used within each RecyclerView item to display the student's name
and possibly additional information like roll number or profile picture.
Layout Structure:
Parent Layout: Utilize a ConstraintLayout as the root layout for the activity.
ConstraintLayout allows for flexible and efficient placement of UI elements,
reducing the need for nested layouts and improving performance.
o
o
TextView: To display the student's name.
o
o
1.
MainActivity:
2.
Purpose: Serves as the primary interface for teachers to view the list of
students and mark their attendance.
o
o
Data Handling:
o
3.
AttendanceHistoryActivity:
4.
o
o
Data Handling:
5.
StudentDetailFragment (optional):
6.
o
o
Data Handling:
kotlin
CopyEdit
data class StudentAttendance(
val studentId: String,
val name: String,
var isPresent: Boolean
)
Explanation:
name: The full name of the student, displayed in the UI.
isPresent: A mutable Boolean indicating the student's attendance status for the
current session.
Usage:
kotlin
CopyEdit
kotlin
CopyEdit
Data Persistence: Upon submission, iterate through the list and save each
record to the local database or send it to the server.
kotlin
CopyEdit
Advantages:
Easy Access: Using studentId as a key allows for quick retrieval and updates of
specific records.
Mutable State: The isPresent property can be easily toggled based on user
interaction.
xml
CopyEdit
<Button
android:id="@+id/btnPresent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/green_button"
android:text="Present"
android:textColor="#FFFFFF" />
Explanation:
<solid>: Sets the fill color of the shape to a specific shade of green (#4CAF50).
<padding>: Adds internal spacing within the button to ensure the text is not
cramped.
android:textColor:
Sets the button's text color to white for better contrast against
the green background.
1.
2.
o
o
Solution:
3.
4.
o
o
Solution:
5.
6.
o
o
o
Solution: