I have a handler for the custom onClick thus:

public class DialogValidator implements OnClickListener {
    private int id;
    private Activity activity;

        protected DialogValidator(Activity activity, int id) {
                this.activity = activity;
                this.id = id;
        }

        @Override
        public void onClick( DialogInterface dialog, int whichButton )
{
        if (whichButton == AlertDialog.BUTTON_POSITIVE) {
                Toast.makeText(activity, "Ok from DialogValidator",
Toast.LENGTH_SHORT).show();
        } else {
                activity.dismissDialog(id);
        }
    }
}

And implement it like this:

@Override
protected Dialog onCreateDialog( int id ) {
...
return new AlertDialog.Builder( this )
        .setIcon( R.drawable.icon )
        .setTitle( R.string.dialog_title )
        .setView( dialogView )
        .setPositiveButton( R.string.button_ok, new DialogValidator
(activity, id))
        .setNegativeButton(R.string.button_cancel, new
DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                }
        })
        .create();
}

I see the Toast but the dialog is dismissed anyway when you click Ok.
In a fuller version I want
to access some of the input fields and only dismiss this dialog if
they are valid. To do that I'd flesh out
the above code where the Toast is - but need it to not dismiss itself.
If I have overriden the parents'
onClick() method as seen, and we know it is being called, why does it
still do that?

Android Academy - http://www.androidacademy.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to