【问题标题】:Can we Create alert Dialog With Radiobuttons and Checkboxes in Blackberry我们可以在黑莓中使用单选按钮和复选框创建警报对话框吗
【发布时间】:2012-04-27 09:08:26
【问题描述】:

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

【问题讨论】:

    标签: dialog blackberry alert


    【解决方案1】:
    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");
                }
            }
        });
    

    希望帮助满..

    【讨论】:

    • 谢谢你。但我对此有一些疑问。我想对按钮执行一些操作 ok。我必须如何写
    【解决方案2】:

    创建 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 );
    
    
    
    }
    
    }
    

    【讨论】:

      【解决方案3】:

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

      UiApplication.getUiApplication().pushScreen(new MyPopup());
      
      
      public class MyPopup extends PopupScreen{
      public MyPopup() {
          super(new VerticalFieldManager(), Field.FOCUSABLE);
          add();//add checkbox , radio buttons here.
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-06-26
        • 1970-01-01
        • 2018-01-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-05
        • 1970-01-01
        相关资源
        最近更新 更多