@Override protected Dialog onCreateDialog(int id) { if (id >= mListData.size()) { return null; } String title = ""; String text = ""; int max = 0; int min = 0; switch (id) { case LIST_POS_DURATION: // Edit notification duration title = "Notification duration \n(1 - " + NotifConfig.maxDuration + ")"; text = String.valueOf(mListData.get(LIST_POS_DURATION)); max = NotifConfig.maxDuration; min = DURATION_MIN; break; case LIST_POS_SUPPRESSION: // Edit suppression window title = "Suppression window \n(0 - " + NotifConfig.maxSuppression + ")"; text = String.valueOf(mListData.get(LIST_POS_SUPPRESSION)); max = NotifConfig.maxSuppression; min = SUPPRESSION_MIN; break; case LIST_POS_REPEAT_HEADER: // Repeat header, ignore. Nothing // to edit here. return null; default: // Any other id would correspond to a repeat value text = String.valueOf(mListData.get(id)); min = mNotifDesc.getMinAllowedRepeat(); max = mListData.get(LIST_POS_DURATION) - 1; title = "Set reminder \n(" + min + " - " + max + ")"; if (min == max) { // Nothing to edit. Do nothing return null; } } // Launch the text edit dialog TrigTextInput ti = new TrigTextInput(this); ti.setTitle(title); ti.setText(text); ti.setNumberMode(true); ti.setNumberModeRange(min, max); ti.setTag(new Integer(id)); ti.setPositiveButtonText("Done"); ti.setNegativeButtonText("Cancel"); ti.setOnClickListener( new TrigTextInput.onClickListener() { @Override public void onClick(TrigTextInput textInput, int which) { if (which == TrigTextInput.BUTTON_POSITIVE) { int listPos = (Integer) textInput.getTag(); if (listPos < mListData.size()) { mListData.set(listPos, Integer.valueOf(textInput.getText())); // Validate the data validateDataAndUpdateView(); } } } }); mDialog = ti.createDialog(); return mDialog; }