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
Contributor
sagar01
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800
My Carrier: Developer

Displaying Images in table Format

Hii,

I have created one sample application using tableLayOut Manager .i have added 5 images in array,but i am getting only first 2 images .and also i am not able to scroll it Horizontally .Hear is my code snippet.

 

public class TableDemo extends MainScreen {

	Bitmap[] bit = new Bitmap[5];
	int _columns;
	 public static final int USE_PREFERRED_SIZE = 3;
	public TableDemo(){
		
		
	bit[0] = Bitmap.getBitmapResource("1.jpg");
		bit[1] = Bitmap.getBitmapResource("2.jpg");
		bit[2] = Bitmap.getBitmapResource("3.jpg");
		bit[3] = Bitmap.getBitmapResource("4.jpg");
		bit[4] =  Bitmap.getBitmapResource("5.jpg");
		TableLayoutManager colFMgr = new TableLayoutManager(new int[]
		                                                              {
		        TableLayoutManager.USE_PREFERRED_SIZE,
		        TableLayoutManager.USE_PREFERRED_SIZE,
		        TableLayoutManager.USE_PREFERRED_SIZE,
		        TableLayoutManager.USE_PREFERRED_SIZE,
		        TableLayoutManager.USE_PREFERRED_SIZE
		    }, Field.FIELD_HCENTER|HORIZONTAL_SCROLL|HORIZONTAL_SCROLLBAR);
		    for(int i= 0;i < bit.length;i++)
		    {
		        colFMgr.add(new BitmapField(bit[i], Field.FOCUSABLE));
		    }
		    
		    add(colFMgr);
	}
	
}

 need your Suggetions.

thanks.

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Displaying Images in table Format

I'm not sure

USE_PREFERRED_SIZE

is the right thing to use, try

SPLIT_REMAINING_WIDTH

 

You might have to scale the Bitmaps to match the screen size you are using. 

Please use plain text.
Contributor
sagar01
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800
My Carrier: Developer

Re: Displaying Images in table Format

i have tried
for(int i= 0;i < bit.length;i++)
{
scalebitmap[i] = new Bitmap(242,120);

bit[i].scaleInto(scalebitmap[i], Bitmap.FILTER_LANCZOS);
colFMgr.add(new BitmapField(bit[i], Field.FOCUSABLE));
System.out.println("Bitmap image Size "+i+""+ bit[i]);
}
but still no effect...
Please use plain text.
Contributor
sagar01
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800
My Carrier: Developer

Re: Displaying Images in table Format

Its not scrolling horizontally..........:smileysad:
Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Displaying Images in table Format

Try adding USE_ALL_WIDTH to the style for the Manager.

Please use plain text.
Contributor
sagar01
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800
My Carrier: Developer

Re: Displaying Images in table Format

Nothing is happened.can i try to use another constructor of tableLayoutManager?
Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Displaying Images in table Format

I would recommend in fact that you review the TableLayoutManager code.  It is not too bad and a good example of a layout manager.  So have a look at it, perhaps even debug the sublayout method.  That method might be, because of your Manager structure, being called with a width set to the screen width.  And that would explain the problem you are having.  Anyway, have a play!

Please use plain text.