I am running the following code in my application. When this code is executed, it displays a global screen alert (OK, Cancel).
final Dialog _dialog = new Dialog(Dialog.D_OK_CANCEL, "Message", Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
Application.getApplication().invokeAndWait(new Runnable() {
public void run() {
ui.pushGlobalScreen(_dialog, 0, UiEngine.GLOBAL_QUEUE);
}
});
If the user clicks 'OK', then I want to go some other class. Else nothing. How is this done?. How can I find out which button was clicked ?
Implement DialogClosedListener interface and override the dialogClosed() method.
this code example will help you.
after your _dialog.show(0); set the listener for dialog close.
_dialog.setDialogClosedListener(new MyDialogClosedListener());
now make inner class as follows:-
public class MyDialogClosedListener implements DialogClosedListener
{
public void dialogClosed(Dialog dialog, int choice)
{
if(dialog.equals(_dialog))
{
if(choice == -1)
{
}
if(choice == 1)
{
your code to implement
}
else if(choice == 2)
{
your code to implement
}
}
}
}