Back to project page myToDo.
The source code is released under:
Apache License
If you think the Android project myToDo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.gutspot.apps.android.mytodo.dialog; //from w w w . ja v a 2 s .c om import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.os.Bundle; import com.gutspot.apps.android.mytodo.MemoActivity; import com.gutspot.apps.android.mytodo.ToDoActivity; import com.gutspot.apps.android.mytodo.dao.MemoDAO; import com.gutspot.apps.android.mytodo.utils.AlertUtil; public class MemoOptionsDialog extends DialogFragment implements OnClickListener { private static final String[] options = new String[] { "??", "??" }; private Context context; private long toDoId; private long memoId; public static MemoOptionsDialog newInstance(Context context, long toDoId, long memoId) { MemoOptionsDialog dialog = new MemoOptionsDialog(); dialog.context = context; dialog.toDoId = toDoId; dialog.memoId = memoId; return dialog; } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("????"); builder.setItems(options, this); return builder.create(); } @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: viewMemo(); break; case 1: deleteMemo(); break; default: } } private void viewMemo() { Intent intent = new Intent(context, MemoActivity.class); intent.putExtra("type", 3); intent.putExtra("todo_id", toDoId); intent.putExtra("memo_id", memoId); context.startActivity(intent); } private void deleteMemo() { String message = "??????Memo?"; String yesLabel = "?"; DialogInterface.OnClickListener yesListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MemoDAO memoDAO = new MemoDAO(context); memoDAO.remove(memoId); ((ToDoActivity) context).updateMemoListView(); } }; String noLabel = "???"; DialogInterface.OnClickListener noListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }; AlertUtil.show(context, message, yesLabel, yesListener, noLabel, noListener); } }