我可以在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;
}
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希望它能解决您的问题