Random header image... Refresh for more!

Let’s Start a Dialog

.Net:

if(MessageBox.Show("Are You Sure?", MessageBoxButtons.YesNo) == DialogResult.Yes) { DoWork(); }

Android:

     AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
     dialogBuilder.setTitle("Save File");
     dialogBuilder.setMessage("Are you sure?");
     dialogBuilder.setPositiveButton("Yes",
       new DialogInterface.OnClickListener()
       {
        public void onClick(DialogInterface dialog, int which)
        {
         doWork();
        }
       });
     dialogBuilder.setNegativeButton("No",
       new DialogInterface.OnClickListener()
       {
        public void onClick(DialogInterface dialog, int which)
        {
         dontDoWork();
        }
       });
     dialogBuilder.setCancelable(true);
     dialogBuilder.setOnCancelListener(
       new DialogInterface.OnCancelListener() {
     
     public void onCancel(DialogInterface dialog)
     {
      dontDoWorkHereEither();
     }
    });
     dialogBuilder.show();

OMG.  WTF.  SERIOUSLY?

Why write just one line of code when TWENTY-NINE will do the same thing just as well?

0 comments

There are no comments yet...

Kick things off by filling out the form below.

Leave a Comment