ANDROID Listview按钮监听器数据库

时间:2015-09-18 10:17:32

标签: android listview

如果我在listview中单击按钮2或3次,则第一个按钮是正在应用的按钮。例如,这没关系,现在 - >缺席。如果我单击Present-> Absent-> Late如果单击后退按钮而不是Late,则会显示Absent。

这是我的代码。

    btncClick.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (status.equalsIgnoreCase(cPresent)) {
                database = context.openOrCreateDatabase("teachers.db", context.MODE_PRIVATE, null);
                database.execSQL("UPDATE tbl_attendance SET status='Absent' WHERE _studID='" + _Attendance2.getStudID() + "' AND _dateID='" + current + "'");

            } else if (status.equalsIgnoreCase("Absent")) {
                database = context.openOrCreateDatabase("teachers.db", context.MODE_PRIVATE, null);
                database.execSQL("UPDATE tbl_attendance SET status='Late' WHERE _studID='" + _Attendance2.getStudID() + "'AND _dateID='" + current + "'");

            } else if (status.equalsIgnoreCase("Late")) {
                database = context.openOrCreateDatabase("teachers.db", context.MODE_PRIVATE, null);
                database.execSQL("UPDATE tbl_attendance SET status='Excuse' WHERE _studID='" + _Attendance2.getStudID() + "'AND _dateID='" + current + "'");
            } else if (status.equalsIgnoreCase("Excuse")) {
                database = context.openOrCreateDatabase("teachers.db", context.MODE_PRIVATE, null);
                database.execSQL("UPDATE tbl_attendance SET status='Present' WHERE _studID='" + _Attendance2.getStudID() + "'AND _dateID='" + current + "'");
            }
            if (btncClick.getText().toString().equalsIgnoreCase("Present")) {
                btncClick.setText("Absent");
            } else if (btncClick.getText().toString().equalsIgnoreCase("Absent")) {
                btncClick.setText("Late");
            } else if (btncClick.getText().toString().equalsIgnoreCase("Late")) {
                btncClick.setText("Excuse");
            } else if (btncClick.getText().toString().equalsIgnoreCase("Excuse")) {
                btncClick.setText("Present");
            }
        }
    });

0 个答案:

没有答案