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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
zapatista
Posts: 5
Registered: ‎06-08-2012
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.

 

Please use plain text.
Developer
simon_hain
Posts: 13,754
Registered: ‎07-29-2008
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
Please use plain text.
New Contributor
zapatista
Posts: 5
Registered: ‎06-08-2012
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.

Please use plain text.
Developer
simon_hain
Posts: 13,754
Registered: ‎07-29-2008
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
Please use plain text.
New Contributor
zapatista
Posts: 5
Registered: ‎06-08-2012
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 ?

Please use plain text.
Developer
simon_hain
Posts: 13,754
Registered: ‎07-29-2008
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
Please use plain text.