这是通过检索 'student_login' 表中的学生数量来计算复选框数量的 admission_sheet.xml 文件。复选框的名称也应该来自表格。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" XYZ" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" PQR" />
<Button
android:id="@+id/bUpdateAttendance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit Attendance" />
</TableLayout>
</ScrollView>
在DbHelper.class中
private static final String STUDENT_TABLE_CREATE = "CREATE TABLE "
+ STUDENT_TABLE + "( s_id INTEGER PRIMARY KEY AUTOINCREMENT , "
+ "s_name TEXT NOT NULL , s_pass TEXT NOT NULL , "
+ "s_roll_no TEXT NOT NULL , " + "s_email TEXT NOT NULL);";
TeacherLoggedInPage.java
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.attendancesheet);
Bundle extras = getIntent().getExtras();
if (savedInstanceState == null) {
extras = getIntent().getExtras();
if (extras == null) {
t_id = (String) null;
} else {
t_id = extras.getString("key");
}
} else {
t_id = (String) savedInstanceState.getSerializable("key");
}
UpdateAttendanceButton = (Button) findViewById(R.id.bUpdateAttendance);
UpdateAttendanceButton.setOnClickListener(this);
}