Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blackberry 如何使用默认图像覆盖已下载图像到black berry列表字段_Blackberry_Listfield - Fatal编程技术网

Blackberry 如何使用默认图像覆盖已下载图像到black berry列表字段

Blackberry 如何使用默认图像覆盖已下载图像到black berry列表字段,blackberry,listfield,Blackberry,Listfield,在过去的两天里,我正在用黑莓(BlackBerry)的网络图像制作列表字段,因为我是新来的。 我正在显示带有一些默认图像的列表字段。当我从web下载实际图像时,它无法替换默认图像。我使用一个线程逐个加载图像。但是图像没有正确地用默认图像覆盖。请帮助我。这是我的代码 列表字段的名称 public void drawListRow(ListField listField,final Graphics graphics,int index, final int y, int width

在过去的两天里,我正在用黑莓(BlackBerry)的网络图像制作列表字段,因为我是新来的。 我正在显示带有一些默认图像的列表字段。当我从web下载实际图像时,它无法替换默认图像。我使用一个线程逐个加载图像。但是图像没有正确地用默认图像覆盖。请帮助我。这是我的代码 列表字段的名称

public void drawListRow(ListField listField,final Graphics graphics,int index,
        final int y, int width)
{
    this.graphics=graphics;
    this.inde=index;
    class ImageDowload extends Task
    {

        void doTask()
        {

            load=new  DowloadImage(picture[inde]);
            if(load.getData()!=null)
            {
                _bmap=load.getBitmap();

                graphics.drawBitmap(3,y+7,placeholder.getWidth(), placeholder.getHeight(),_bmap, 0, 0);
            }


        }



    }

    taskWorker.addTask(new ImageDowload());  

    String text=(String) get(listField, index);
String pricedetails=price[index];
    graphics.setColor(rgb);
    graphics.setFont(Utility.getBigFont(DConfig.getFSize()+4));
    graphics.drawBitmap(3,y+7,placeholder.getWidth(), placeholder.getHeight(),placeholder, 0, 0);
graphics.drawText(text,100,y+25);  
graphics.drawText(pricedetails+" $",420,y+25); 
graphics.drawLine(0, y+74, DConfig.disWidth, y+74);

}

你肯定不想把你的请求放在
drawListRow()
中,因为每次需要重新绘制时它都会触发


创建ListField(或任何有意义的时间)时,只需开始下载所有图像。在
drawListRow()
中,当您要绘制位图时,检查下载的位图是否存在,如果它确实绘制了位图,如果没有绘制默认值。现在,随着每个图像下载的完成,只需将列表字段
invalidate()
,它就会绘制新下载的图像。

只需将
DownloadImage
任务和
taskWorker.addTask()
调用移动到构造函数中,并将它们保存到哈希表或其他地方。然后在
drawListRow()
中,查看
ht.get(key)
处是否存在某些内容。如果它确实绘制,则绘制默认值。在不知道你的代码是如何工作的情况下,这可能是相当多的代码。我的应用程序中出现了另一个异常,请帮助我这里是链接