Dialog Show In Android
<p>This is my show dialog code.</p>

<pre><code>    @Override
    protected Dialog onCreateDialog(int id) {
    switch (id) {
    case 0:
        return new AlertDialog.Builder(this)
        .setIcon(R.drawable.ic_launcher)
        .setTitle("Select Reminder which you want to delete")
        .setPositiveButton("OK",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton)
            {
                Toast.makeText(getBaseContext(), "OK clicked!", Toast.LENGTH_SHORT).show();
                check  = 1;
            }
        }
        )

        .setNegativeButton("Cancel",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton)
            {
                Toast.makeText(getBaseContext(), "Cancel clicked!", Toast.LENGTH_SHORT).show();
                check = 2;
            }
        }
        )

        .setMultiChoiceItems(items, itemsChecked,
        new DialogInterface.OnMultiChoiceClickListener() {
            public void onClick(DialogInterface dialog,
                    int which, boolean isChecked) {

                Toast.makeText(getBaseContext(), items[which] + (isChecked ? " checked!":" unchecked!") + which, Toast.LENGTH_SHORT).show();
            }
        }
        ).create();
    }
        return null;
    }
</code></pre>

<p>and this is function where i call it.</p>

<pre><code>   public void show()
    {

        showDialog(0);

        if(check == 1)
        {
            Toast.makeText(this, "ok" + check, Toast.LENGTH_LONG).show();
        }
        else if (check == 2)
        {
            Toast.makeText(this, "Cancel" + check, Toast.LENGTH_LONG).show();
        }
    }
</code></pre>

<p>I m facing bit problem n confused from what happening that "showDialog(0);" function works well but when i press "ok" button then dialog disappears and it only show toast written in onclicklistener of "ok" button, but the code written after "showDialog(0);" to show another toast is like unreachable, mean the variable "check" (which is global) whose value i set 1 or 2 in onclicklisteners of "ok" and "cancel" button and use them in if-else condition after  "showDialog(0);" to show different toast but function "show" ends without checking if-else condition. I did'nt understand what is actually happening here?</p>
