-1

これは、「student_login」テーブルで学生の数を取得することによってチェック ボックスの数が計算されるattends_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);

    }
4

1 に答える 1

0

これがあなたがする必要があることです、

1) チェックボックスを動的に作成します。

2) Database の名前に基づいて、checkBox に名前を付けます。

3)それらをレイアウトに追加します(LinearLayoutの場合があります)

ここに同様の回答があります チェックボックスを動的に追加する方法

あなたのレイアウトxmlは以下のようになるはずです

<Linear Layout With orientation Vertical>
  <Linear Layout with Orientation Vertical /> // Add CheckBoxes in this Layout, By taking its ID in the code.
  <Update BUtton>
</Linear Layout closing for top LL>
于 2013-08-11T11:20:12.537 に答える