0

我正在尝试下面提到的从服务器下载图像的代码,但它不起作用并且没有给我任何错误。如果我使用了任何错误,请提出建议。当我从浏览器访问 URL 时,它正在向我显示图像。

int pos; 
public void DisplayContent()
{
    f = (Form)createContainer(GlobalVariables.Theme, "ContentPageWise");
    body = (Container) findByName("Containerbody", f);
    Display_Image = new Image[Page_Details.size()];

        for(int i=0;i<Page_Details.size();i++)
        {
            Hashtable<String,String> hash_page = Page_Details.get(i);
            Log.p("imagepath:"+hash_page.get("imgPage"));
            pos=i;
            GetImagesFromserver(hash_page.get("imgPage"));
            Container Cpage = new Container(new BoxLayout(BoxLayout.Y_AXIS));
            Label pic = new Label();
            pic.setIcon(Display_Image[i]);
            Cpage.addComponent(pic);
            body.addComponent(Cpage);
         }

}

void GetImagesFromserver(String Imagepath)
{
    //eg. url like this: http://lmsasr.gizmosupport.com/presentation/tele/internet.jpg
    ImageDownloadService imageDownloadService =
            new ImageDownloadService(Imagepath, actionListener);
    InfiniteProgress ip = new InfiniteProgress();
    imageDownloadService.setDisposeOnCompletion(ip.showInifiniteBlocking());
    NetworkManager.getInstance().addToQueue(imageDownloadService);

}

ActionListener actionListener = new ActionListener()
{
    public void actionPerformed(ActionEvent evt)
    {

        NetworkEvent n = (NetworkEvent) evt;
        Display_Image[pos] = ((Image)n.getMetaData());
    }
};
4

0 回答 0