我想参加其中我首先要选择一个从微调器类,然后日期,然后单击添加出勤我应该被导航到下一页,我已经在其他表中存储的所有学生id将显示,并与一个复选框将在那里标记出勤(所以id应直接来自学生详细信息)表),然后当我提交它时,它应该做一个考勤表,其中将有4列(日期和主题从上一页,身份证和出席/缺席从这一页)。
考勤.java:
package com.example.uni_assist;
import androidx.appcompat.app.AppCompatActivity;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import java.util.Calendar;
public class Attendance extends AppCompatActivity {
Spinner spinnersubject;
Button viewattend, addattend;
ImageButton datebutton;
EditText attenddate;
private Calendar cal;
private int day;
private int month;
private int dyear;
public static final String Firebase_Server_URL = "https://uni-assist-44b84-default-rtdb.firebaseio.com/";
String SubjectHolder,AttendDateHolder;
Firebase firebase;
DatabaseReference databaseReference;
public static final String Database_Path = "Attendance";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_attendance);
spinnersubject = findViewById(R.id.spinnersub);
String[] items = new String[]{"AI", "DSR", "MAD", "TOC", "SDS", ".NET"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, items);
spinnersubject.setAdapter(adapter);
datebutton = (ImageButton) findViewById(R.id.DateImageButton);
cal = Calendar.getInstance();
day = cal.get(Calendar.DAY_OF_MONTH);
month = cal.get(Calendar.MONTH);
dyear = cal.get(Calendar.YEAR);
attenddate = (EditText) findViewById(R.id.DateEditText);
datebutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
showDialog(0);
}
});
Firebase.setAndroidContext(Attendance.this);
firebase = new Firebase(Firebase_Server_URL);
databaseReference = FirebaseDatabase.getInstance().getReference(Database_Path);
addattend = (Button) findViewById(R.id.buttonadd);
spinnersubject = (Spinner) findViewById(R.id.spinnersub);
addattend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Attendance.this, AddAttendance.class);
startActivity(intent);
}
});
}
@Override
@Deprecated
protected Dialog onCreateDialog(int id) {
return new DatePickerDialog(this, datePickerListener, dyear, month, day);
}
private DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
attenddate.setText(selectedDay + " / " + (selectedMonth + 1) + " / "
+ selectedYear);
}
};
}`
活动\ u attention.xml:
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=".HomepageS">
<Button
android:id="@+id/buttonview"
android:layout_width="320dp"
android:layout_height="63dp"
android:text="View Attendance"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.494"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.976" />
<TextView
android:id="@+id/textView59"
android:layout_width="116dp"
android:layout_height="42dp"
android:text="Select Subject"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.207"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.162" />
<Spinner
android:id="@+id/spinnersub"
android:layout_width="130dp"
android:layout_height="46dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.84"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.16" />
<ImageButton
android:id="@+id/DateImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cropToPadding="true"
android:src="@drawable/calendar_icon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.699"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.311" />
<EditText
android:id="@+id/DateEditText"
android:layout_width="138dp"
android:layout_height="44dp"
android:hint="Enter date"
android:gravity="center"
android:background="#ffffff"
android:editable="false"
android:ems="10"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.175"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.322"/>
<Button
android:id="@+id/buttonadd"
android:layout_width="320dp"
android:layout_height="63dp"
android:text="Add Attendance"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.527"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.459" />
</androidx.constraintlayout.widget.ConstraintLayout>
addAttention.java地址:
package com.example.uni_assist;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class AddAttendance extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_attendance);
}
}
活动\添加\出勤.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".AddAttendance">
<TextView
android:id="@+id/textView60"
android:layout_width="148dp"
android:layout_height="44dp"
android:text="Add Attendance"
android:gravity="center"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.071" />
<Button
android:id="@+id/buttonaddattend"
android:layout_width="173dp"
android:layout_height="43dp"
android:text="Save Attendance"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.526"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.963" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="373dp"
android:layout_height="480dp"
app:layout_constraintBottom_toBottomOf="@+id/buttonaddattend"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.553" />
</androidx.constraintlayout.widget.ConstraintLayout>`
attendancedetails.java:(getter和setter文件)
<TextView
android:id="@+id/textView60"
android:layout_width="148dp"
android:layout_height="44dp"
android:text="Add Attendance"
android:gravity="center"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.071" />
<Button
android:id="@+id/buttonaddattend"
android:layout_width="173dp"
android:layout_height="43dp"
android:text="Save Attendance"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.526"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.963" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="373dp"
android:layout_height="480dp"
app:layout_constraintBottom_toBottomOf="@+id/buttonaddattend"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.553" />
</androidx.constraintlayout.widget.ConstraintLayout> `
recycleradapterview2.java文件:
package com.example.uni_assist;
public class RecyclerViewAdapter2 extends RecyclerView.Adapter<RecyclerViewAdapter2.ViewHolder> {
Context context;
List<Attendancedetails> MainImageUploadInfoList;
public RecyclerViewAdapter2(Context context, List<Attendancedetails> TempList) {
this.MainImageUploadInfoList = TempList;
this.context = context;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_items2, parent, false);
ViewHolder viewHolder = new ViewHolder(view);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Attendancedetails attendance = MainImageUploadInfoList.get(position);
holder.StudentIdTextView.setText(attendance.getAttendId());
holder.StudentAttend.setText(attendance.getAttendPresent());
}
@Override
public int getItemCount() {
return MainImageUploadInfoList.size();
}
class ViewHolder extends RecyclerView.ViewHolder {
public TextView StudentIdTextView;
public CheckBox StudentAttend;
public ViewHolder(View itemView) {
super(itemView);
StudentIdTextView = (TextView) itemView.findViewById(R.id.ShowStudentIdTextView1);
StudentAttend = (CheckBox) itemView.findViewById(R.id.checkBox);
}
}
}
活动\u recycler \u items2.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
card_view:cardElevation="5dp"
card_view:contentPadding="5dp"
card_view:cardCornerRadius="5dp"
card_view:cardMaxElevation="5dp"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ECEFF1"
android:padding="10dp">
<TextView
android:id="@+id/StudentId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Student Id: "
android:textColor="#000"
android:textSize="20dp" />
<TextView
android:id="@+id/ShowStudentIdTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="61dp"
android:layout_marginLeft="61dp"
android:layout_marginTop="3dp"
android:layout_toEndOf="@+id/StudentId"
android:layout_toRightOf="@+id/StudentId"
android:gravity="center"
android:text="Show Student Id"
android:textColor="#000"
android:textSize="20dp" />
<TextView
android:id="@+id/AttendPresent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/StudentEmail"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginStart="6dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="30dp"
android:gravity="center"
android:text="Attendance"
android:textColor="#000"
android:textSize="20dp" />
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_below="@+id/ShowStudentIdTextView1"
android:layout_marginStart="85dp"
android:layout_marginLeft="85dp"
android:layout_marginTop="-2dp"
android:layout_toEndOf="@+id/AttendPresent"
android:layout_toRightOf="@+id/AttendPresent"
android:gravity="center"
android:text="Present" />
</RelativeLayout>
</androidx.cardview.widget.CardView>`
所以,我不知道如何从学生详细信息表和显示在添加考勤页,然后从那里我必须采取的复选框和存储在考勤表的输入值。
在此处输入图像描述
暂无答案!
目前还没有任何答案,快来回答吧!