How to display a dialog in BlackBerry

1.7k Views Asked by At

How do I display a dialog to the user asking him if he wants to continue, with a choice of yes or no?

4

There are 4 best solutions below

0
On

use JOptionPane :

int res = JOptionPane.showConfirmDialog(null,"Do you want to continue ?");
if (int == 0){
   // code for continue
}
else {

}
0
On
Dialog d = new Dialog("Do you want to continue?", new String[]{"Yes","No"},  new int[]{Dialog.OK,Dialog.CANCEL}, Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.QUESTION)){
                    public void setChangeListener(FieldChangeListener listener) {
                        if(d.getSelectedValue() == Dialog.OK){
                             //true part                                
                        }
                        else{
                             //false part
                        }
                    };
                };
d.show();
0
On

You need to use one of the Dialogs provided by BB like Dialog.ask(someNumber,"Your message");

0
On

Came here late but maybe helpful to someone in future:

int ans =  Dialog.ask(Dialog.D_YES_NO, "Do you want to continue?", Dialog.YES);

    if (ans == Dialog.YES) 
        // Continue
    else
        // Do not Continue

The third parameter states the default selected option which is set to the Yes option.

Here's an article on how to work with different types of Blackberry dialogs.