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
Developer
Posts: 264
Registered: ‎10-05-2010
My Device: Not Specified
Accepted Solution

Aligning fields ARGH!

Would someone please point me to the holy grail reference on how aligning works?

 

I have... How do I get these things to align right???

 

 

HorizontalFieldManager fmLine2 = new HorizontalFieldManager( HorizontalFieldManager.NO_VERTICAL_SCROLL | HorizontalFieldManager.USE_ALL_WIDTH );

displayLapTitle    = new LCDTitleField("Lap ", LabelField.FIELD_RIGHT);	 displayLap         = new LCDField(""+0, LabelField.FIELD_RIGHT);	 displayTimer2Title = new LCDTitleField("  ", LabelField.FIELD_RIGHT);	 displayTimer2      = new LCDField(lcdFormat(0), LabelField.FIELD_RIGHT);

fmLine2.add(displayLapTitle);
fmLine2.add(displayLap);	
fmLine2.add(displayTimer2Title);
fmLine2.add(displayTimer2);

add(fmLine2);

 

 

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Aligning fields ARGH!

Here are a few rules:

  • HorizontalFieldManager respects vertical alignment styles but ignores horizontal alignment styles and lays fields out left-to-right.
  • VerticalFieldManager respects horizontal alignmnet styles but ignores vertical alignment styles and lays fields out top-to-bottom.

So to align your four fields at the right, you can do something like this:

 

VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_WIDTH);
HorizontalFieldManager fmLine2 = new HorizontalFieldManager(FIELD_RIGHT);

displayLapTitle    = new LCDTitleField("Lap ");
displayLap         = new LCDField(""+0);
displayTimer2Title = new LCDTitleField("  ");
displayTimer2      = new LCDField(lcdFormat(0));

fmLine2.add(displayLapTitle);
fmLine2.add(displayLap);	
fmLine2.add(displayTimer2Title);
fmLine2.add(displayTimer2);

vfm.add(fmLine2);
add(vfm);



Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 264
Registered: ‎10-05-2010
My Device: Not Specified

Re: Aligning fields ARGH!

That did it.Thanks.

 

I can see where you tire of the complexity and just end up writing all your own controls eventually...

Contributor
Posts: 20
Registered: ‎03-04-2011
My Device: 9800
My Carrier: application developer

Re: Aligning fields ARGH!

hello sir ..

please help me on this i m taking data from server and i am Aligning the field from right but that value i m not able to get it from right ... it is coming like this ...1234567.00

      12345.00

       5678.00

it should come like this  

     123456.00

           3456.00

        68998.00

     123456.00

 

please help me and correct my code i m waitng for reply

here is my code :::

 

 public class LowerCreditors extends VerticalFieldManager implements FieldChangeListener {
 // class Lower extends
 public LowerCreditors(){
   super(VerticalFieldManager.VERTICAL_SCROLL);  
   
   
       int length = CrDrList.VendorNameArr.length;
     
     for(int i=0; i<length; i++ ){
  
     final LabelField Value =   new LabelField(CrDrList.VendorValArr[i], LabelField.RIGHT);
    
   add(new LabelField());
    
         final LabelField Button  = new LabelField( CrDrList.VendorNameArr[i] ,LabelField.FOCUSABLE);
     
       
       
       
     HorizontalFieldManager hrMgr = new HorizontalFieldManager();
  
 VerticalFieldManager vfMgr2 = new VerticalFieldManager()
 {
     public int getPreferredWidth() {
 
 return Display.getWidth() - Value.getWidth()-130;
 }
 protected void sublayout(int maxWidth, int maxHeight) {
 super.sublayout(getPreferredWidth(), Value.getPreferredHeight());
 setExtent(getPreferredWidth(),Value.getPreferredHeight());
 }
 
 };
  
 vfMgr2.add(Button);
  
/////////////////////COde for value printing//////////////////////  
   
  VerticalFieldManager vfMgr1 = new VerticalFieldManager(VerticalFieldManager.RIGHTMOST);
 HorizontalFieldManager hrMgr3 = new HorizontalFieldManager(FIELD_RIGHT){
  
 public int getPreferredWidth() {
 
 return Display.getWidth() - Value.getWidth()-10;
 }
    protected void sublayout(int maxWidth, int maxHeight) {
 super.sublayout(getPreferredWidth(), Value.getPreferredHeight());
 setExtent(getPreferredWidth(),Value.getPreferredHeight());
 }
  
  
 };
 
 vfMgr1.add(Value);
 
  
hrMgr.add(vfMgr2);
 
hrMgr3.add(vfMgr1);
 
add(hrMgr);
 
    }
 }

 

 

 

 

please help me any1 i m stuck in that probm....

thankyou in advance

 

 

 

 

 

Highlighted
Contributor
Posts: 21
Registered: ‎08-31-2011
My Device: Touch 4.5
My Carrier: Airtel

Re: Aligning fields ARGH!

Thanks, I had been looking for this.

Thanks a lot again.