Codenameone:警报对话框消息

Codenameone:警报对话框消息,codenameone,Codenameone,我们需要这种格式的对话框消息,并进行查找和填充 你能告诉我怎么解决吗。我的应用程序需要在所有平台(Android、iOS、Windows)上得到支持,我不想为所有平台分别编写本机代码 实际上,在Codename One中定制外观更容易,因为所有内容都是用Java编写的,您可以定制任何内容的外观 为了简单起见,我使用了代码而不是样式,这会更好,您可以在主题设计器中自定义对话框UIID和其他UIID,以获得更大的灵活性并使其更简单。但是,这需要许多屏幕截图和解释,因此我在代码中进行了自定义: Fo

我们需要这种格式的对话框消息,并进行查找和填充


你能告诉我怎么解决吗。我的应用程序需要在所有平台(Android、iOS、Windows)上得到支持,我不想为所有平台分别编写本机代码

实际上,在Codename One中定制外观更容易,因为所有内容都是用Java编写的,您可以定制任何内容的外观

为了简单起见,我使用了代码而不是样式,这会更好,您可以在主题设计器中自定义
对话框
UIID和其他UIID,以获得更大的灵活性并使其更简单。但是,这需要许多屏幕截图和解释,因此我在代码中进行了自定义:

Form f = new Form("Test");
Button b = new Button("Show Dialog");
f.add(b);
b.addActionListener(e -> {
    Dialog dlg = new Dialog("Authentication");
    Style dlgStyle = dlg.getDialogStyle();
    dlgStyle.setBorder(Border.createEmpty());
    dlgStyle.setBgTransparency(255);
    dlgStyle.setBgColor(0xffffff);

    Label title = dlg.getTitleComponent();
    title.setIcon(finalDuke.scaledHeight(title.getPreferredH()));
    title.getUnselectedStyle().setFgColor(0xff);
    title.getUnselectedStyle().setAlignment(Component.LEFT);

    dlg.setLayout(BoxLayout.y());
    Label blueLabel = new Label();
    blueLabel.setShowEvenIfBlank(true);
    blueLabel.getUnselectedStyle().setBgColor(0xff);
    blueLabel.getUnselectedStyle().setPadding(1, 1, 1, 1);
    blueLabel.getUnselectedStyle().setPaddingUnit(Style.UNIT_TYPE_PIXELS);
    dlg.add(blueLabel);
    TextArea ta = new TextArea("This is the text you want to appear in the dialog, this might line break if the text is too long...");
    ta.setEditable(false);
    ta.setUIID("DialogBody");
    ta.getAllStyles().setFgColor(0);
    dlg.add(ta);

    Label grayLabel = new Label();
    grayLabel.setShowEvenIfBlank(true);
    grayLabel.getUnselectedStyle().setBgColor(0xcccccc);
    grayLabel.getUnselectedStyle().setPadding(1, 1, 1, 1);
    grayLabel.getUnselectedStyle().setPaddingUnit(Style.UNIT_TYPE_PIXELS);
    dlg.add(grayLabel);

    Button ok = new Button(new Command("OK"));
    ok.getAllStyles().setBorder(Border.createEmpty());
    ok.getAllStyles().setFgColor(0);
    dlg.add(ok);
    dlg.showDialog();
});
f.show();     


我建议在主题设计器中进行对话框自定义,并使用外观更好的9块图像边框。

我应该在项目中的何处添加此自定义代码。在StateMachine.java或StateMachineBase.java或其他任何地方?您可以在任何地方编写代码以显示对话框。您可以自定义所有对话框,使其看起来像这样,例如,当使用Android模拟器皮肤运行时,它们应该看起来非常类似。这来自Android本机主题,您可以从github存储库的主题目录下载。