0

我想在黑莓中进行多create a alert dialog with radiobuttonsor alert dialog with Checkboxes的单选。在android中是可能的。但我想在黑莓中。我在google中搜索过。但我没有任何解决方案。请为这个问题提供任何建议r有用的链接。

4

3 回答 3

4
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.component.CheckboxField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.DialogFieldManager;

public class CheckboxInputDialog extends Dialog{

  private CheckboxField checkboxEditField;

  public CheckboxInputDialog(String choices[],int values[], String label){
    super(label, choices,values,Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.INFORMATION), Dialog.GLOBAL_STATUS);

    checkboxEditField  = new CheckboxField("Lablel",false);
    net.rim.device.api.ui.Manager delegate = getDelegate();
    if( delegate instanceof DialogFieldManager){
        DialogFieldManager dfm = (DialogFieldManager)delegate;
        net.rim.device.api.ui.Manager manager =dfm.getCustomManager();
        if( manager != null ){
            manager.insert(checkboxEditField, 0);
        }
    }

 }    

}

现在按以下方式调用此对话框...

    String choices[] = { "OK", "CANCEL" };
    int values[] = { Dialog.OK, Dialog.CANCEL };
    CheckboxInputDialog d = new CheckboxInputDialog(choices,values,"Dialog Label");
    d.show();

输出将是:

在此处输入图像描述

获取 OK 和 Cancel 按钮的事件。

String choices[] = { "OK", "CANCEL" };
    int values[] = { Dialog.OK, Dialog.CANCEL };
    final CheckboxInputDialog d = new CheckboxInputDialog(choices, values,"Dialog Label");
    UiApplication.getUiApplication().invokeLater(new Runnable() {
        public void run() {
            int iResponse = d.doModal();
            if (iResponse == 0) {
                System.out.println("Press Ok");
            }else{
                System.out.println("Press Cancel");
            }
        }
    });

希望帮助满..

于 2012-04-27T09:33:22.873 回答
0

创建 popupScreen 并在此屏幕中添加单选按钮和复选框。

public class Custom_Popup extends PopupScreen {

public Custom_Popup() {
    // TODO Auto-generated constructor stub
    super( new VerticalFieldManager(Manager.VERTICAL_SCROLL),
Field.NON_FOCUSABLE | Field.USE_ALL_WIDTH );



}

}
于 2012-04-27T09:21:20.190 回答
0

在您的活动中,按此屏幕。

UiApplication.getUiApplication().pushScreen(new MyPopup());


public class MyPopup extends PopupScreen{
public MyPopup() {
    super(new VerticalFieldManager(), Field.FOCUSABLE);
    add();//add checkbox , radio buttons here.
}
于 2012-04-27T09:22:49.753 回答