简体   繁体   中英

How to display a dialog in BlackBerry

如何向用户显示对话框,询问他是否要继续,选择是还是否?

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();

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 .

您需要使用BB提供Dialog之一,例如Dialog.ask(someNumber,"Your message");

use JOptionPane :

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

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM