0

从过去的两天开始,我正在用黑莓中的网络图像做列表字段,因为我是新手。我正在显示带有一些默认图像的列表字段。当我从网络下载实际图像时,它无法替换默认图像。我使用一个线程一张一张地加载图像。但是图像没有正确覆盖默认图像。请帮助me.Here 是我的列表字段代码。

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);

}
4

1 回答 1

1

您绝对不想将您的问题放在 中drawListRow(),因为每次必须重新绘制时它都会触发。

只需在创建 ListField 时(或任何有意义的时间)开始下载所有图像。在drawListRow()你去绘制位图时,检查下载的是否存在,如果它确实绘制了那个,如果没有绘制默认值。现在每个图像下载都完成了,只有invalidate()ListField 它将绘制新下载的图像。

于 2011-06-21T16:30:36.777 回答