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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800
My Carrier: Developer

Not able to align images and Titles horizontally.

Hii,

i have created array of Images and Array of Labels to show in one image and one Title in one line horizontally.but i am getting all my images and Title in a single horizontalManager.i am not understanding how to align them now so that i can see One Image and one Title at each line in a list.this is my code snippet.

hr1 = new HorizontalFieldManager(HORIZONTAL_SCROLL|HORIZONTAL_SCROLLBAR){
				protected void onFocus(int direction) {
    		        invalidate();
    		        super.onFocus(direction);
    		    }

   		    protected void onUnfocus() {
    		        invalidate();
    		        super.onUnfocus();
    		    }

    		    public void paint(Graphics graphics) {
    		        if (isFocus()) {
   		        	    graphics.setBackgroundColor(Color.WHITE);
   		                graphics.clear();
    		        }
   		        super.paint(graphics);
    		    }
			};

	System.out.println("after arg++++++++++");
		                                                  for(int j = 0; j< ResponseHandler_Review.vectrImgUrl.size(); j++){
		            	arg = new String[ResponseHandler_Review.vectrImgUrl.size()];
		            	System.out.println("arg values......... = " +arg);
		           	 arg[j] = String.valueOf(ResponseHandler_Review.vectrImgUrl.elementAt(j));
		           	 System.out.println("Array of arg "+j+" = " +arg[j]);
		           	 bit = new Bitmap[ResponseHandler_Review.vectrImgUrl.size()];
			            scaleBit = new Bitmap[ResponseHandler_Review.vectrImgUrl.size()];
			            System.out.println("after bit array+++++++ = " +scaleBit.length);
                          
		           	 System.out.println("Vector element is "+j+" = "+arg[j]);
					 bit[j] = response.getImage(arg[j]);
					 
					scaleBit[j] = new Bitmap(162, 122);
					bit[j].scaleInto(scaleBit[j], Bitmap.FILTER_LANCZOS);
					hr1.add(new BitmapField(scaleBit[j]));
					System.out.println("vectrImgUrl size =  " + ResponseHandler_Review.vectrImgUrl.size());
		            }

			for(int i=0;i<ResponseHandler_Review.vectrTitle.size();i++){
label[i] = new LabelField(ResponseHandler_Review.vectrTitle.elementAt(i), Field.FIELD_VCENTER|Field.FOCUSABLE)
					{
						public int getPreferredWidth() 
						{
							return Display.getWidth()-150;
						}
						protected boolean navigationClick(int status, int time) {
							fieldChangeNotify(0);

							return true;
							
						}
						
					};			
					label[i].setFont(font);
					label[i].setChangeListener(this);
					label[i].setPadding(5, 5, 0, 5);
					
		             System.out.println("print all the labels++++++++++++"+label[i]);
					
					hr1.add(label[i]);	
					
					

			}
			ver.add(hr1);			
			ver.add(new SeparatorField());
			vertical.add(ver);
			add(vertical);

 this wat i have did. i am getting all the images and all the titles in one line horizontally.need your suggestions..

Thanks.

Super Contributor
Posts: 257
Registered: ‎05-05-2011
My Device: 9700
My Carrier: AT&T

Re: Not able to align images and Titles horizontally.

try to insert image and label in VerticalFieldManager for each image-label pair, then insert these VerticalFieldManagers in your HorizontalFieldManager

 

but I'm not sure if I understood right what you were trying to say, thoughSmiley Happy

Contributor
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800
My Carrier: Developer

Re: Not able to align images and Titles horizontally.

i have added both images and Title in same Horizontal manager.and then adding that horizontal manager in one vertical manager.and then again adding that vertical manager in another Vertical Manager..
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Not able to align images and Titles horizontally.

Have you looked at using another Manager, like TableLayoutManager or GridFieldManager?

 

If these are new to you, search the forum for more information on them. 

Highlighted
Contributor
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800
My Carrier: Developer

Re: Not able to align images and Titles horizontally.

ok.but is there any problem in this type of approach??
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Not able to align images and Titles horizontally.

Not really.  But using multiple VFMs and HFMs is not particularly efficient, especially with adding and removing Fields and there are quirks with each that might make alignment more difficult. And there is the normal scrolling problem to, when you scrol up form a Field and end up somewhere unexpected. 

 

I would recommend TableLayoutManager as the code is quite useful as an example of a Maanger implementation.