Example usage for android.widget TimePicker setIs24HourView

List of usage examples for android.widget TimePicker setIs24HourView

Introduction

In this page you can find the example usage for android.widget TimePicker setIs24HourView.

Prototype

public void setIs24HourView(@NonNull Boolean is24HourView) 

Source Link

Document

Sets whether this widget displays time in 24-hour mode or 12-hour mode with an AM/PM picker.

Usage

From source file:de.androvdr.activities.ChannelsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_WHATS_ON:
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.extendedchannels_whats_on);
        dialog.setTitle(R.string.channels_whats_on);

        final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        final DatePicker dp = (DatePicker) dialog.findViewById(R.id.channels_datePicker);
        final TimePicker tp = (TimePicker) dialog.findViewById(R.id.channels_timePicker);
        tp.setIs24HourView(DateFormat.is24HourFormat(getApplicationContext()));
        if (sp.contains("whats_on_hour")) {
            tp.setCurrentHour(sp.getInt("whats_on_hour", 0));
            tp.setCurrentMinute(sp.getInt("whats_on_minute", 0));
        }//from w  ww.ja v  a 2 s.  c o  m

        Button button = (Button) dialog.findViewById(R.id.channels_cancel);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        button = (Button) dialog.findViewById(R.id.channels_search);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Editor editor = sp.edit();
                editor.putInt("whats_on_hour", tp.getCurrentHour());
                editor.putInt("whats_on_minute", tp.getCurrentMinute());
                editor.commit();

                SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy hh:mm");
                try {
                    long time = df.parse(dp.getDayOfMonth() + "." + (dp.getMonth() + 1) + "." + dp.getYear()
                            + " " + tp.getCurrentHour() + ":" + tp.getCurrentMinute()).getTime() / 1000;
                    getController().whatsOn(time);
                } catch (ParseException e) {
                    logger.error("Couldn't get date from pickers", e);
                }
                dialog.dismiss();
            }
        });
        return dialog;
    default:
        return super.onCreateDialog(id);
    }
}

From source file:com.simplaapliko.wakeup.sample.ui.DialogDateTime.java

private void initUiWidgets(View rootView) {
    Log.d(TAG, "initUiWidgets()");

    // set up tabhost
    TabHost tabHost = (TabHost) rootView.findViewById(R.id.tabhost);
    tabHost.setup();//from   w w  w  .  j  a  v  a2s  . co  m

    TabHost.TabSpec tabSpec;

    // adding tabs
    tabSpec = tabHost.newTabSpec("date");
    tabSpec.setIndicator("Date");
    tabSpec.setContent(R.id.date);
    tabHost.addTab(tabSpec);

    tabSpec = tabHost.newTabSpec("time");
    tabSpec.setIndicator("Time");
    tabSpec.setContent(R.id.time);
    tabHost.addTab(tabSpec);

    TimePicker timePicker = (TimePicker) rootView.findViewById(R.id.time);
    timePicker.setIs24HourView(true); //set to true, because it is more compact
    timePicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);

    // init time picker before OnTimeChangedListener() is set
    // otherwise minutes will be set to current time, once setCurrentHour() is called
    timePicker.setCurrentHour(mCalendar.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(mCalendar.get(Calendar.MINUTE));

    timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
        @Override
        public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {

            mCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            mCalendar.set(Calendar.MINUTE, minute);
            mCalendar.set(Calendar.SECOND, 0);
        }
    });

    DatePicker datePicker = (DatePicker) rootView.findViewById(R.id.date);
    datePicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    datePicker.init(mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH),
            mCalendar.get(Calendar.DAY_OF_MONTH), new DatePicker.OnDateChangedListener() {
                @Override
                public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

                    mCalendar.set(Calendar.YEAR, year);
                    mCalendar.set(Calendar.MONTH, monthOfYear);
                    mCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                }
            });
}

From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.DayFragment.java

public void inflateLayout(int iPos) {

    String sIdSubject = Session.getSingleInstance().getDatabaseHandler().getSubjects().get(iPos).getsId();

    // String sIdSubject = Session.getSingleInstance().getActivity(iPos).getId_subject();        
    long lDuration = Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sIdSubject);

    // List of activities to inflate history
    List<ActividadDb> lADb = Session.getSingleInstance().getDatabaseHandler().getActivities(sIdSubject);

    // Duration// ww w  .  j a  va 2  s.c  om
    DateUtils du = new DateUtils();
    TextView t = (TextView) rootView.findViewById(R.id.tvDuration);
    t.setText(du.duration(lDuration));

    // Time picker
    TimePicker timePicker = (TimePicker) rootView.findViewById(R.id.tpTask);
    timePicker.setIs24HourView(true);
    timePicker.setCurrentHour(0);
    timePicker.setCurrentMinute(45);

    // Button image view   
    ImageView iv = (ImageView) rootView.findViewById(R.id.ivActionActivity);
    int currentStatus = Session.getSingleInstance().getActivity(iPos).getStatus();
    if (currentStatus == ActivitySession.STATUS_STOPPED) {
        Drawable d = getResources().getDrawable(R.drawable.play);
        iv.setImageDrawable(d);
    } else {
        Drawable d = getResources().getDrawable(R.drawable.stop);
        iv.setImageDrawable(d);
    }

    // History      
    if (lADb.size() != 0) {

        LinearLayout llHistory = (LinearLayout) rootView.findViewById(R.id.llHistory);
        TextView tvHeader = (TextView) llHistory.findViewById(R.id.tvHeaderHisory);
        tvHeader.setVisibility(View.VISIBLE);

        for (int i = 0; i < lADb.size(); i++) {

            ActividadDb adb = lADb.get(i);

            LinearLayout llCheckItemWrapper = (LinearLayout) mInflater.inflate(R.layout.check_item, null);
            // Passing order as param so it can be removed
            llCheckItemWrapper.setTag(i);

            LinearLayout liContent = (LinearLayout) llCheckItemWrapper.getChildAt(0);

            TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp);
            tvTimeStamp.setText(Constants.TIME_FORMAT.format(adb.getlDateCheckIn()));
            // Passing checkin time in mills as tag
            tvTimeStamp.setTag(Long.valueOf(adb.getlDateCheckIn()));

            TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration);
            tvDurRecord.setText(" [" + du.duration(adb.getlDateCheckIn(), adb.getlDateCheckOut()) + "]");
            // Passing subject id as parameter        
            tvDurRecord.setTag(adb.getsIdSubject());

            llHistory.addView(mInflater.inflate(R.layout.tag_divider, llHistory, false), 1);
            llHistory.addView(llCheckItemWrapper, 2);

        }

    }

}

From source file:de.escoand.readdaily.ReminderDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    TimePicker v = new TimePicker(getContext());

    settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
    hour = settings.getInt(SETTINGS_HOUR, 9);
    minute = settings.getInt(SETTINGS_MINUTE, 0);

    v.setIs24HourView(true);
    v.setOnTimeChangedListener(this);
    v.setCurrentHour(hour);/*from www.  j  a v a 2s .co  m*/
    v.setCurrentMinute(minute);

    return new AlertDialog.Builder(getContext()).setView(v).setPositiveButton(R.string.button_ok, this)
            .setNegativeButton(R.string.button_cancel, this).create();
}

From source file:com.flowzr.activity.DateFilterActivity.java

private void prepareDialog(Dialog dialog, Calendar c) {
    DatePicker dp = (DatePicker) dialog.findViewById(R.id.date);
    dp.init(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), null);
    TimePicker tp = (TimePicker) dialog.findViewById(R.id.time);
    tp.setIs24HourView(is24HourFormat(this));
    tp.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
    tp.setCurrentMinute(c.get(Calendar.MINUTE));
}

From source file:tmnt.wheresyourcar.ParkActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.park);//from w w  w  . j a v a2 s.com
    locationClient = new LocationClient(this, this, this);
    TimePicker time = (TimePicker) findViewById(R.id.num_pick);
    time.setIs24HourView(true);
    context = getApplicationContext();

    if (checkPlayServices()) {
        gcm = GoogleCloudMessaging.getInstance(this);
        regid = getRegistrationId(context);

        if (regid.isEmpty()) {
            registerInBackground();
        }
    } else {
        Log.i(TAG, "No valid Google Play Services APK found.");
    }
}

From source file:org.tvbrowser.tvbrowser.TvBrowser.java

private void updateTvData() {
    if (!TvDataUpdateService.IS_RUNNING) {
        Cursor test = getContentResolver().query(TvBrowserContentProvider.CONTENT_URI_CHANNELS, null,
                TvBrowserContentProvider.CHANNEL_KEY_SELECTION + "=1", null, null);

        if (test.getCount() > 0) {
            AlertDialog.Builder builder = new AlertDialog.Builder(TvBrowser.this);

            RelativeLayout dataDownload = (RelativeLayout) getLayoutInflater()
                    .inflate(R.layout.dialog_data_update_selection, getParentViewGroup(), false);

            final Spinner days = (Spinner) dataDownload
                    .findViewById(R.id.dialog_data_update_selection_download_days);
            final CheckBox pictures = (CheckBox) dataDownload
                    .findViewById(R.id.dialog_data_update_selection_download_picture);

            final Spinner autoUpdate = (Spinner) dataDownload
                    .findViewById(R.id.dialog_data_update_preferences_auto_update_selection_type);
            final Spinner frequency = (Spinner) dataDownload
                    .findViewById(R.id.dialog_data_update_preferences_auto_update_selection_frequency);
            final CheckBox onlyWiFi = (CheckBox) dataDownload
                    .findViewById(R.id.dialog_data_update_preferences_auto_update_selection_type_connection);
            final TextView timeLabel = (TextView) dataDownload
                    .findViewById(R.id.dialog_data_update_preferences_auto_update_selection_time_label);
            final TextView time = (TextView) dataDownload
                    .findViewById(R.id.dialog_data_update_preferences_auto_update_selection_time);
            time.setTextColor(onlyWiFi.getTextColors());

            String currentDownloadDays = PrefUtils.getStringValue(R.string.DAYS_TO_DOWNLOAD,
                    R.string.days_to_download_default);

            final String[] possibleDownloadDays = getResources().getStringArray(R.array.download_days);

            for (int i = 0; i < possibleDownloadDays.length; i++) {
                if (currentDownloadDays.equals(possibleDownloadDays[i])) {
                    days.setSelection(i);
                    break;
                }//ww  w.  ja  v  a  2 s. c  o m
            }

            pictures.setChecked(
                    PrefUtils.getBooleanValue(R.string.LOAD_PICTURE_DATA, R.bool.load_picture_data_default));

            String currentAutoUpdateValue = PrefUtils.getStringValue(R.string.PREF_AUTO_UPDATE_TYPE,
                    R.string.pref_auto_update_type_default);
            String currentAutoUpdateFrequency = PrefUtils.getStringValue(R.string.PREF_AUTO_UPDATE_FREQUENCY,
                    R.string.pref_auto_update_frequency_default);

            if (currentAutoUpdateValue.equals("0")) {
                frequency.setEnabled(false);
                onlyWiFi.setEnabled(false);
                timeLabel.setEnabled(false);
                time.setEnabled(false);
                frequency.setVisibility(View.GONE);
                onlyWiFi.setVisibility(View.GONE);
                timeLabel.setVisibility(View.GONE);
                time.setVisibility(View.GONE);
            } else if (currentAutoUpdateValue.equals("1")) {
                autoUpdate.setSelection(1);
                timeLabel.setEnabled(false);
                time.setEnabled(false);
                timeLabel.setVisibility(View.GONE);
                time.setVisibility(View.GONE);
            } else if (currentAutoUpdateValue.equals("2")) {
                autoUpdate.setSelection(2);
            }

            final String[] autoFrequencyPossibleValues = getResources()
                    .getStringArray(R.array.pref_auto_update_frequency_values);

            for (int i = 0; i < autoFrequencyPossibleValues.length; i++) {
                if (autoFrequencyPossibleValues[i].equals(currentAutoUpdateFrequency)) {
                    frequency.setSelection(i);
                    break;
                }
            }

            onlyWiFi.setChecked(PrefUtils.getBooleanValue(R.string.PREF_AUTO_UPDATE_ONLY_WIFI,
                    R.bool.pref_auto_update_only_wifi_default));

            final AtomicInteger currentAutoUpdateTime = new AtomicInteger(PrefUtils.getIntValue(
                    R.string.PREF_AUTO_UPDATE_START_TIME, R.integer.pref_auto_update_start_time_default));

            Calendar now = Calendar.getInstance();

            now.set(Calendar.HOUR_OF_DAY, currentAutoUpdateTime.get() / 60);
            now.set(Calendar.MINUTE, currentAutoUpdateTime.get() % 60);
            now.set(Calendar.SECOND, 0);
            now.set(Calendar.MILLISECOND, 0);

            time.setText(DateFormat.getTimeFormat(TvBrowser.this).format(now.getTime()));

            autoUpdate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                    frequency.setEnabled(position != 0);
                    onlyWiFi.setEnabled(position != 0);

                    if (position != 0) {
                        frequency.setVisibility(View.VISIBLE);
                        onlyWiFi.setVisibility(View.VISIBLE);
                    } else {
                        frequency.setVisibility(View.GONE);
                        onlyWiFi.setVisibility(View.GONE);
                    }

                    timeLabel.setEnabled(position == 2);
                    time.setEnabled(position == 2);

                    if (position == 2) {
                        timeLabel.setVisibility(View.VISIBLE);
                        time.setVisibility(View.VISIBLE);
                    } else {
                        timeLabel.setVisibility(View.GONE);
                        time.setVisibility(View.GONE);
                    }
                }

                @Override
                public void onNothingSelected(AdapterView<?> parent) {

                }
            });

            View.OnClickListener onClickListener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    AlertDialog.Builder b2 = new AlertDialog.Builder(TvBrowser.this);

                    LinearLayout timeSelection = (LinearLayout) getLayoutInflater().inflate(
                            R.layout.dialog_data_update_selection_auto_update_time, getParentViewGroup(),
                            false);

                    final TimePicker timePick = (TimePicker) timeSelection
                            .findViewById(R.id.dialog_data_update_selection_auto_update_selection_time);
                    timePick.setIs24HourView(DateFormat.is24HourFormat(TvBrowser.this));
                    timePick.setCurrentHour(currentAutoUpdateTime.get() / 60);
                    timePick.setCurrentMinute(currentAutoUpdateTime.get() % 60);

                    b2.setView(timeSelection);

                    b2.setPositiveButton(android.R.string.ok, new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            currentAutoUpdateTime
                                    .set(timePick.getCurrentHour() * 60 + timePick.getCurrentMinute());

                            Calendar now = Calendar.getInstance();

                            now.set(Calendar.HOUR_OF_DAY, currentAutoUpdateTime.get() / 60);
                            now.set(Calendar.MINUTE, currentAutoUpdateTime.get() % 60);
                            now.set(Calendar.SECOND, 0);
                            now.set(Calendar.MILLISECOND, 0);

                            time.setText(DateFormat.getTimeFormat(TvBrowser.this).format(now.getTime()));
                        }
                    });
                    b2.setNegativeButton(android.R.string.cancel, null);

                    b2.show();
                }
            };

            time.setOnClickListener(onClickListener);
            timeLabel.setOnClickListener(onClickListener);

            builder.setTitle(R.string.download_data);
            builder.setView(dataDownload);

            builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String value = possibleDownloadDays[days.getSelectedItemPosition()];

                    Editor settings = PreferenceManager.getDefaultSharedPreferences(TvBrowser.this).edit();

                    if (PrefUtils.getStringValueAsInt(R.string.PREF_AUTO_UPDATE_RANGE,
                            R.string.pref_auto_update_range_default) < Integer.parseInt(value)) {
                        settings.putString(getString(R.string.PREF_AUTO_UPDATE_RANGE), value);
                    }

                    settings.putString(getString(R.string.DAYS_TO_DOWNLOAD), value);
                    settings.putBoolean(getString(R.string.LOAD_PICTURE_DATA), pictures.isChecked());
                    settings.putString(getString(R.string.PREF_AUTO_UPDATE_TYPE),
                            String.valueOf(autoUpdate.getSelectedItemPosition()));

                    if (autoUpdate.getSelectedItemPosition() == 1
                            || autoUpdate.getSelectedItemPosition() == 2) {
                        settings.putString(getString(R.string.PREF_AUTO_UPDATE_FREQUENCY),
                                autoFrequencyPossibleValues[frequency.getSelectedItemPosition()]);
                        settings.putBoolean(getString(R.string.PREF_AUTO_UPDATE_ONLY_WIFI),
                                onlyWiFi.isChecked());

                        if (autoUpdate.getSelectedItemPosition() == 2) {
                            settings.putInt(getString(R.string.PREF_AUTO_UPDATE_START_TIME),
                                    currentAutoUpdateTime.get());
                        }
                    }

                    settings.commit();

                    IOUtils.handleDataUpdatePreferences(TvBrowser.this);

                    Intent startDownload = new Intent(TvBrowser.this, TvDataUpdateService.class);
                    startDownload.putExtra(TvDataUpdateService.TYPE, TvDataUpdateService.TV_DATA_TYPE);
                    startDownload.putExtra(getResources().getString(R.string.DAYS_TO_DOWNLOAD),
                            Integer.parseInt(value));

                    startService(startDownload);

                    updateProgressIcon(true);
                }
            });
            builder.setNegativeButton(android.R.string.cancel, null);
            builder.show();
        } else {
            Cursor test2 = getContentResolver().query(TvBrowserContentProvider.CONTENT_URI_CHANNELS, null, null,
                    null, null);

            boolean loadAgain = test2.getCount() < 1;

            test2.close();

            selectChannels(loadAgain);
        }

        test.close();
    }
}

From source file:course1778.mobileapp.safeMedicare.Main.FamMemFrag.java

public void onClick(DialogInterface di, int whichButton) {
    // get strings from edittext boxes, then insert them into database
    ContentValues values = new ContentValues(DatabaseHelper.CONTENT_VALUE_COUNT);
    ContentValues drugInteractionValues = new ContentValues(4);
    Dialog dlg = (Dialog) di;
    EditText title = (EditText) dlg.findViewById(R.id.title);
    TimePicker tp = (TimePicker) dlg.findViewById(R.id.timePicker);
    Spinner mySpinner = (Spinner) dlg.findViewById(R.id.spinner);
    String fre = mySpinner.getSelectedItem().toString();
    EditText dosage = (EditText) dlg.findViewById(R.id.dosage);
    EditText instruction = (EditText) dlg.findViewById(R.id.instruction);
    RadioGroup radioButtonGroup = (RadioGroup) dlg.findViewById(R.id.radioGroup);
    int radioButtonID = radioButtonGroup.getCheckedRadioButtonId();
    View radioButton = radioButtonGroup.findViewById(radioButtonID);
    int shape = radioButtonGroup.indexOfChild(radioButton) / 2;
    int Fre;/*  ww  w. jav a2 s.c om*/
    //int day = 0;
    int monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0, saturday = 0, sunday = 0;

    // clear array list
    drug_interaction_list.clear();
    curr_drug_interaction_list.clear();

    // loop through database
    crsInteractions.moveToPosition(-1);
    while (crsInteractions.moveToNext()) {
        // drug names
        drugName = crsInteractions.getString(crsInteractions.getColumnIndex(DatabaseHelper.SHEET_1_DRUG_NAMES));

        // corresponding interacted drugs/foods
        interactionName = crsInteractions
                .getString(crsInteractions.getColumnIndex(DatabaseHelper.SHEET_1_DRUG_INTERACTIONS));

        // interaction result
        interactionResult = crsInteractions
                .getString(crsInteractions.getColumnIndex(DatabaseHelper.SHEET_1_INTERACTION_RESULT));

        // medication name entered by user
        medNameFieldTxt = textView.getText().toString();

        // check if newly entered medication name matches current drug name
        if (drugName.equals(medNameFieldTxt)) {
            /**if found, check if the corresponding interaction
             * drug in the list of all added drugs by user
             */
            if (db.isNameExitOnDB(interactionName)) {
                // interaction found
                Log.d("myinteraction", "Found Interaction");

                String interaction_result = medNameFieldTxt + "/" + interactionName + "\n";

                // only insert new drug interactions if they have not yet exist
                if (!dbInteraction.isDrugInteractionExist(medNameFieldTxt, interactionName)) {
                    // insert the drug interaction into our new dynamic drug interaction db
                    drugInteractionValues.put(DatabaseInteractionHelper.USR_NAME,
                            ParseUser.getCurrentUser().getUsername());
                    drugInteractionValues.put(DatabaseInteractionHelper.DRUG_NAME, medNameFieldTxt);
                    drugInteractionValues.put(DatabaseInteractionHelper.DRUG_INTERACTION, interactionName);
                    drugInteractionValues.put(DatabaseInteractionHelper.DRUG_INTERACTION_SHOW,
                            DatabaseInteractionHelper.DRUG_INTERACTION_SHOW_TRUE);

                    dbInteraction.getWritableDatabase().insert(DatabaseInteractionHelper.TABLE,
                            DatabaseInteractionHelper.DRUG_NAME, drugInteractionValues);
                }

                drug_interaction_list.add(interaction_result);
                curr_drug_interaction_list.add(interactionName);
            }
        }
    }

    Log.d("mydatabase3", DatabaseUtils.dumpCursorToString(dbInteraction.getCursor()));

    // display all iteractions in pop window if there is any
    String interaction_results = "\n";
    for (int i = 0; i < curr_drug_interaction_list.size(); i++) {
        String interaction = medNameFieldTxt + " & " + curr_drug_interaction_list.get(i) + "\n\n";
        interaction_results = interaction_results.concat(interaction);
    }

    if (drug_interaction_list.size() != 0) {
        // inflate a dialog to display the drug interactions warning
        LayoutInflater inflater = getActivity().getLayoutInflater();
        View resultView = inflater.inflate(R.layout.drug_interaction_result, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        builder.setTitle(R.string.drug_interaction_result_title).setView(resultView)
                // go to drug interaction list button
                .setNegativeButton(R.string.drug_interaction_list, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // drug interaction page
                        DrugInteractions drugInterac = new DrugInteractions();
                        FragmentTransaction transaction;
                        transaction = getFragmentManager().beginTransaction();
                        transaction.replace(R.id.fragmentContainer, drugInterac);
                        transaction.addToBackStack(null);
                        // Commit the transaction
                        transaction.commit();
                    }
                })

                // ok button
                .setPositiveButton(R.string.dismiss, null).show();

        TextView interactionResultView = (TextView) resultView.findViewById(R.id.resultView);

        // add warning message into the pop up window
        interaction_results = interaction_results.concat(getString(R.string.interaction_warning));

        // display on pop up window
        interactionResultView.setText(interaction_results);
    }

    // write the list of drug interactions into file
    Helpers.writeToFile(getContext(), drug_interaction_list, "drug_interaction_list");

    Log.d("mydatabase", DatabaseUtils.dumpCursorToString(db.getCursor()));

    if (fre == "Ten Times a Day") {
        Fre = 10;
    } else if (fre == "Twice a Day") {
        Fre = 2;
    } else if (fre == "Three Times a Day") {
        Fre = 3;
    } else if (fre == "Four Times a Day") {
        Fre = 4;
    } else if (fre == "Five Times a Day") {
        Fre = 5;
    } else if (fre == "Six Times a Day") {
        Fre = 6;
    } else if (fre == "Seven Times a Day") {
        Fre = 7;
    } else if (fre == "Eight Times a Day") {
        Fre = 8;
    } else if (fre == "Nine Times a Day") {
        Fre = 9;
    } else {
        Fre = 1;
    }

    if (((CheckBox) dlg.findViewById(R.id.MonCheck)).isChecked()) {
        monday = monday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.TueCheck)).isChecked()) {
        tuesday = tuesday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.WedCheck)).isChecked()) {
        wednesday = wednesday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.ThuCheck)).isChecked()) {
        thursday = thursday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.FriCheck)).isChecked()) {
        friday = friday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.SatCheck)).isChecked()) {
        saturday = saturday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.SunCheck)).isChecked()) {
        sunday = sunday + 1;
    }

    // clear focus before retrieving the min and hr
    tp.clearFocus();

    int tpMinute = tp.getCurrentMinute();
    int tpHour = tp.getCurrentHour();
    // an order number to order the list view items
    int orderNum = tpHour * 60 + tpMinute;
    tp.setIs24HourView(true);

    String titleStr = title.getText().toString();
    String timeHStr = Helpers.StringFormatter(tpHour, "00");
    String timeMStr = Helpers.StringFormatter(tpMinute, "00");
    String dosageStr = dosage.getText().toString();
    String instructionStr = instruction.getText().toString();

    Log.d("mytime", Integer.toString(tpHour));
    Log.d("mytime", Integer.toString(tpMinute));

    values.put(DatabaseHelper.USRNAME, ParseUser.getCurrentUser().getUsername());
    values.put(DatabaseHelper.TITLE, titleStr);
    values.put(DatabaseHelper.TIME_H, timeHStr);
    values.put(DatabaseHelper.TIME_M, timeMStr);
    values.put(DatabaseHelper.FREQUENCY, Fre);
    //values.put(DatabaseHelper.DAY, day);

    values.put(DatabaseHelper.MONDAY, monday);
    values.put(DatabaseHelper.TUESDAY, tuesday);
    values.put(DatabaseHelper.WEDNESDAY, wednesday);
    values.put(DatabaseHelper.THURSDAY, thursday);
    values.put(DatabaseHelper.FRIDAY, friday);
    values.put(DatabaseHelper.SATURDAY, saturday);
    values.put(DatabaseHelper.SUNDAY, sunday);

    values.put(DatabaseHelper.DOSAGE, dosageStr);
    values.put(DatabaseHelper.INSTRUCTION, instructionStr);
    values.put(DatabaseHelper.SHAPE, shape);
    values.put(DatabaseHelper.ORDER_NUM, orderNum);

    Bundle bundle = new Bundle();
    // add extras here..
    bundle.putString(DatabaseHelper.TITLE, title.getText().toString());
    bundle.putString(DatabaseHelper.TIME_H, timeHStr);
    bundle.putString(DatabaseHelper.TIME_M, timeMStr);
    bundle.putInt(DatabaseHelper.FREQUENCY, Fre);
    //bundle.putInt(DatabaseHelper.DAY, day);

    bundle.putInt(DatabaseHelper.MONDAY, monday);
    bundle.putInt(DatabaseHelper.TUESDAY, tuesday);
    bundle.putInt(DatabaseHelper.WEDNESDAY, wednesday);
    bundle.putInt(DatabaseHelper.THURSDAY, thursday);
    bundle.putInt(DatabaseHelper.FRIDAY, friday);
    bundle.putInt(DatabaseHelper.SATURDAY, saturday);
    bundle.putInt(DatabaseHelper.SUNDAY, sunday);

    bundle.putString(DatabaseHelper.DOSAGE, dosageStr);
    bundle.putString(DatabaseHelper.INSTRUCTION, instructionStr);
    bundle.putInt(DatabaseHelper.SHAPE, shape);
    bundle.putInt(DatabaseHelper.ORDER_NUM, orderNum);
    //Alarm alarm = new Alarm(getActivity().getApplicationContext(), bundle);

    // get unique notifyId for each alarm
    int length = title.length();
    for (int i = 0; i < length; i++) {
        notifyId = (int) titleStr.charAt(i) + notifyId;
    }
    notifyId = Integer.parseInt(timeHStr + timeMStr);

    // saving it into parse.com
    ParseObject parseObject = new ParseObject(Helpers.PARSE_OBJECT);
    parseObject.put(DatabaseHelper.USRNAME, ParseUser.getCurrentUser().getUsername());
    parseObject.put(DatabaseHelper.TITLE, titleStr);
    parseObject.put(DatabaseHelper.TIME_H, timeHStr);
    parseObject.put(DatabaseHelper.TIME_M, timeMStr);
    parseObject.put(DatabaseHelper.FREQUENCY, Fre);
    //parseObject.put(DatabaseHelper.DAY, day);

    parseObject.put(DatabaseHelper.MONDAY, monday);
    parseObject.put(DatabaseHelper.TUESDAY, tuesday);
    parseObject.put(DatabaseHelper.WEDNESDAY, wednesday);
    parseObject.put(DatabaseHelper.THURSDAY, thursday);
    parseObject.put(DatabaseHelper.FRIDAY, friday);
    parseObject.put(DatabaseHelper.SATURDAY, saturday);
    parseObject.put(DatabaseHelper.SUNDAY, sunday);

    parseObject.put(DatabaseHelper.DOSAGE, dosageStr);
    parseObject.put(DatabaseHelper.INSTRUCTION, instructionStr);
    parseObject.put(DatabaseHelper.SHAPE, shape);
    parseObject.put(DatabaseHelper.NOFITY_ID, notifyId);
    parseObject.put(DatabaseHelper.ORDER_NUM, orderNum);
    parseObject.saveInBackground();

    task = new InsertTask().execute(values);
}