How to define the action for the button on this custom dialog box?

advertisements

I make a custom Dialog like as :

public class CustomDialog extends Dialog {
     public CustomDialog(String s) {
    super(s, new String[] {"View","Cancel"}, new int [] {1,2}, 1,         Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.FOCUSABLE);

    }

How can I set action for "View button" and " Cancel button " ? I searched and not found what I have to do . Please help me !


Check out this code.. this might help you..

import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.HorizontalFieldManager;

public class CustomAlertDialog extends Dialog {

    public CustomAlertDialog() {
        super("Your Custom message for Dialoug" , null, null, Dialog.DISCARD, null, Dialog.VERTICAL_SCROLL);

        HorizontalFieldManager hfm = new HorizontalFieldManager();

        ButtonField view = null;

        view = new ButtonField("view") {
            protected boolean navigationClick(int status, int time) {
            // do what ever you want
            return true;
            }

            protected boolean keyChar(char key, int status, int time) {
            // do what ever you want
            return true;
            }
        };

        ButtonField cancel = null;
        cancel = new ButtonField("Cancel") {
            protected boolean navigationClick(int status, int time) {
            // do what ever you want
            return true;
            }

            protected boolean keyChar(char key, int status, int time) {
            // do what ever you want
            return true;
            }
        };
    hfm.add(view);
    hfm.add(cancel);

    this.add(hfm);
    }
}