我是否可以在Dialog.show中插入图像,显示为代号One

问题描述 投票:1回答:1

我可以在Dialog.show中插入图像,显示为代号1,如果可以,请提供示例。这是我想出的:

  img.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent evt) {
                    Dialog.show("Image:", images(value.toString()), new Command("Cancel"));
                }
            });

   public ImageViewer images(String id) {
    int id2 = Integer.parseInt(id);
    String img = ServiceTask.getInstance().ReturnImage(id2);
    Image placeholder = Image.createImage(getWidth() / 3 - 4, getWidth() / 3 - 4, 0xbfc9d2);
    EncodedImage encImage = EncodedImage.createFromImage(placeholder, false);
    ImageViewer img1 = new ImageViewer(URLImage.createToStorage(encImage, "file" + img,
            "http://localhost/projectname/web/images/" + img));

    return img1;
}
java codenameone
1个回答
0
投票
您可以通过以下示例对此进行存档:

AlertDialog.Builder imageDialog = new AlertDialog.Builder(MainActivity.this); imageDialog.setTitle("Title"); ImageView myImage = new ImageView(MainActivity.this); imageDialog.setView(myImage); imageDialog.setNegativeButton("ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); imageDialog.show();

对于

CODEONE,您可以按照此示例操作

Image alertImage = com.codename1.ui.util.Resources.getGlobalResources().getImage(alertImageId); alertImage.scaled(500, 500); Command commands[] = {new Command("Aceptar"),new Command("Cancelar")}; Label lblAlert = new Label(alertImage); lblAlert.setSize(new Dimension(500,500)); Command result = Dialog.show(alertTitle, lblAlert, commands);
您可以在此处参考更多示例https://www.codenameone.com/manual/components.html希望它能解决您的问题
© www.soinside.com 2019 - 2024. All rights reserved.