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
New Developer
praveensingh18
Posts: 13
Registered: ‎02-10-2012
My Device: Curve 9300 3G
Accepted Solution

Custom Layout Manager

Hi All

 

I am having trouble with creating a custom layout manager. I have extended the Manager Class and implemented the getPreferredWidth() , getPreferredHeight() and sublayout(int width, int height) methods but I two LabelFields are not getting displayed.

 

I would like to set the two label fields as shown in the picture below but I don't fully understand creating custom layouts. I understand getPreferredWidth() and getPreferredHeight() sets the width and height of the manager but I am confused with the sublauout(int width, int height) method and the layoutChild and setPositionchild(field, int, int).

 

I would appreciate it if anyone could point out any tutorials, examples and notes for understanding custom layouts.

 

Thanks,

Praveen Singh

 

 

 

AppScr.png

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Custom Layout Manager

These two knowledge base articles are absolutely required read before you attempt creating your own custom managers (which are one of the most advanced topics in BlackBerry GUI):

Create a custom layout manager for a screen

How to Extend Manager

 

The following thread contains some finished sublayout code which should also give you enough food for thought:

AbsoluteFieldManager on OS prior to 5.0

 

Even after you read all three, you will have enough questions - come back here and ask.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
New Developer
praveensingh18
Posts: 13
Registered: ‎02-10-2012
My Device: Curve 9300 3G

Re: Custom Layout Manager

Hi arkadyz

 

 

Thank you for the help.  I solved the problem I had, I was trying to extend the Manager class and setPreferredWidth() to return Display.getWidth() and setPreferredHeight() to return the height of the first field.  My problem was that I was adding two LabelFields to my custom manager and was trying to keep them on the same line, which meant my int y variable was set as zero and my int x variable was changing but these two variables x and y is also used in setExtent(x,y); so I was getting setExtent(x,0); which caused my labelfields not to show. 

 

 

protected void sublayout(int width, int height) {
                  int x = 0;
                  int y = 0;
                 

                  for (int i = 0; i < getFieldCount(); i++) {
                         Field field = getField(i);
                         layoutChild(field, width, height);
                         setPositionChild(field, x, y);
                         x += field.getWidth() + 90;
                         y += 0;
                  }
                  setExtent(x, y+getField(0).getHeight());
}

Please use plain text.