Android Open Source - Attendance-AutoCounter Course Modify Dialog

From Project

Back to project page Attendance-AutoCounter.


The source code is released under:

GNU General Public License

If you think the Android project Attendance-AutoCounter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.etonn.attendance_autocounter;
/*  www  . jav  a  2s.  com*/
import android.annotation.TargetApi;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.etonn.attendance_autocounter.db.DBManager;

 * Created by Zeshi on 11/23/14.
public class CourseModifyDialog extends DialogFragment {
    DBManager db;

    public Dialog onCreateDialog(Bundle savedInstanceState) {
        db = new DBManager(getActivity());

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        final LayoutInflater inflater = getActivity().getLayoutInflater();
        //set custom dialog view, in this case is two edittext box
        final View mView = inflater.inflate(R.layout.dialog_course_modify, null);
                .setTitle("Modify Course")
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialogInterface, int i) {
                                EditText courseName = (EditText) mView.findViewById(;
                                EditText headcount = (EditText) mView.findViewById(;
                                //set input type ---- only number in dialog_course_modify.xml

                                String courseNameS = courseName.getText().toString();
                                String headcountS = headcount.getText().toString();

                                if (courseNameS.equals("") || headcountS.equals("")) {
                                    Toast.makeText(getActivity(), "please fill in both two blanks", Toast.LENGTH_SHORT).show();
                                //can't modify course name now in DB
                                else {
                                    if (db.queryCourseByName(courseNameS) == null) {
                                        Toast.makeText(getActivity(), "No such a course", Toast.LENGTH_SHORT).show();
                                    } else {
                                        int headcountI = Integer.parseInt(headcountS);
                                        db.updateCourseByName(courseNameS, headcountI);


                .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialogInterface, int i) {
        return builder.create();

Java Source Code List