Reputation: 77
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 !
Upvotes: 0
Views: 626
Reputation: 10964
Attach a DialogClosedListener
to your CustomDialog
using Dialog.setDialogClosedListener()
. When someone clicks either of the buttons, the DialogClosedListener.dialogClosed()
method will be called and the button index will be passed as the choice
parameter.
Upvotes: 1
Reputation: 5941
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);
}
}
Upvotes: 0