views:

50

answers:

2

I have 50/100 image url with specific text, i add them in vector, add listfield with callback,

I am downloading the image every time with a function call UrlToImage I am facing problem, the list is too slow , download icon showing on the top right side of simulator.

UrlToImage img = new UrlToImage(imageUrl);
bit = img.getbitmap();
pic = new BitmapField(bit); 
g.drawBitmap(xpos, y+10, bit.getWidth(), bit.getHeight(), bit, DrawStyle.LEFT,0);

Can't scroll smoothly throughout the list.

Any idea, comments.

A: 

Your formatting is all messed up, but if I understand you correctly, you're downloading upon every callback?

One way to avoid that is create a thread that kicks off when the screen is needed, and asynchronously do the downloads (once each!) and stick the images in a cache. Then the drawListRow callback just pulls from the cache.

cjp
A: 

It appears as though your code is executing inside the paint method. This all occurs on the UI thread (meaning that you block the UI, make a request, wait for a response, set the image, and then draw the image, every time a paint occurs). Seeing as a request can take about 3 seconds, your UI will freeze for that long.

What you should be doing it fetching your image in the constructor of your class, set an instance variable of your class, and then g.drawBitmap with that instance variable.

In short, the only code in your paint method should be the g.drawBitmap, in order to prevent the choppy scrolling.

gburgoon