我们可以在Blackberry中使用单选按钮和复选框创建警报对话框

时间:2012-04-27 09:08:27

标签: blackberry dialog alertdialog

我希望create a alert dialog with radiobuttons单一选择or alert dialog with Checkboxes for blackiselection in blackberry.it可能在android.but我想在blackberry.i搜索google.but我没有'得到任何解决方案。请给出任何有用的链接来解决这个问题。

3 个答案:

答案 0 :(得分: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();

输出将是:

enter image description here

获取确定和取消按钮的事件。

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");
            }
        }
    });

希望帮助全..

答案 1 :(得分:0)

创建弹出屏幕,在此屏幕中,您可以添加单选按钮和复选框。

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 );



}

}

答案 2 :(得分:0)

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

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


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