Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 5
Registered: ‎06-08-2012
My Device: Curve 8520
My Carrier: INDOSAT

Thread Image from JSON

here is my code:

 

ParseJSON

 

my image thread connection : LINE 126

 

i am trying to display image in ListField

 

Can someone please help me out with this. The format of what I'm trying is something like this

 

------------

| image |  LabelField1

|           |  LabelField2

-------------

 

Thanks.

 

Developer
Posts: 16,651
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Thread Image from JSON

welcome to the support forums.

download the image and update the vector (/datastructure) you use for your listfield, then invalidate it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Contributor
Posts: 5
Registered: ‎06-08-2012
My Device: Curve 8520
My Carrier: INDOSAT

Re: Thread Image from JSON

in drawListRow i try this

path = (String) imagePaths.elementAt(index);
bit = connectServerForImage(path);
Bitmap CHECKMARK_IMAGE = Bitmap.getBitmapResource("img/aristo.jpg");
if (bit == null) { bit = CHECKMARK_IMAGE; }

g.drawBitmap(xText, y + yText, 80, 200, bit, 0, 0);

 but can't scroll smoothly throughout the list. Any idea, comments.

Developer
Posts: 16,651
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Thread Image from JSON

do not do networking or other blocking operations on the UI, see http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Contributor
Posts: 5
Registered: ‎06-08-2012
My Device: Curve 8520
My Carrier: INDOSAT

Re: Thread Image from JSON

i also try this

private class imgConnection extends Thread
{      
        public imgConnection() {
                super();
        }
       
        public void run() {            
                
                try {
					for (int i = 0; i < imagePaths.size(); i++)
					{
						final int index = i;                              
						String path = imagePaths.elementAt(index).toString();
						bit = connectServerForImage(path);
						Bitmap CHECKMARK_IMAGE = Bitmap.getBitmapResource("img/aristo.jpg");
						if (bit == null) { bit = CHECKMARK_IMAGE; }
						bit = resizeBitmap(bit, 70, 70);                                               
						image.addElement(bit);
																																				   
					}
                }
                catch (Exception e)
                {
					System.out.println(e.toString());                        
                }
               
                UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {        
                        _list.setSize(image.size());
                        subManager.add(_list);                        
                        screen.invalidate();
                        }  
                        });
               
               
        }
}

public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
	bit = (Bitmap) image.elementAt(index);
	g.drawBitmap(xText, y + yText, 80, 200, bit, 0, 0);
}

 but is not working ?

Developer
Posts: 16,651
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Thread Image from JSON

it would be better to download the pictures one by one, and update the screen for each.

you can display the listfield directly, either with a placeholder bitmap or without the picture, and update it with each downloaded picture.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter