View Single Post
  (#2 (permalink)) Old
richard.puckett Offline
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Posts: 212
Join Date: Oct 2007
Location: Seattle, WA
Model: 8800
PIN: N/A
Carrier: AT&T
Default 06-23-2008, 12:00 PM

It sounds like what you want is a Manager function (if I'm understanding correctly).

Say you have a Manager composed of some text fields - say, a VerticalFieldManager which represents a column in a grid. Here's some pseudocode which shows approximately how to set a column to the greatest width of all contained fields. HTH.

Code:
protected void sublayout(int width, int height) {
   int maxWidth = 0;
   int yOffset = 0;
   int fieldCount = getFieldCount();

   for (int i = 0; i < fieldCount; i++) {
      Field field = getField(i);
      layoutChild(field, width, height);
      setPositionChild(field, 0, yOffset);
      yOffset += field.getHeight();
      maxWidth = Math.max(maxWidth, field.getWidth();
   }

   setExtent(maxWidth, yOffset);
}


Do your homework and know how to ask a good question.
   
Reply With Quote