tags:

views:

833

answers:

4

dear friends,

i want to display dialog/popup window of "are you sure you want to delete this entry"

on click of button Delete

if i press ok it should delete that entry other wise nothing..

i have written click listner of those buttons but dont know who to invoke dialog or pop and its functionality...

any help would be appriciated.

+6  A: 

You could use the alert builder for this:

new AlertDialog.Builder(this)
    .setTitle("Delete entry")
    .setMessage("Are you sure you want to delete this entry?")
    .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        public void onClick(/* don't remember the signature by heart... */) { 
            // continue with delete
        }
     })
    .setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(/* don't remember the signature by heart... */) { 
            // do nothing
        }
     })
     .show();
David Hedlund
A: 

here is everything you need to know Dev Guide - Dialogs

Schwiz
A: 

here is simple implementation

sagar
A: 

Just be careful when you want to dismiss the dialog - use dialog.dismiss(). In my first attempt I used dismissDialog(0) (which I probably copied from some place) which sometimes works. Using the object the system supplies sounds like a safer choice. :)

ro-tex