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
Highlighted
Contributor
Posts: 14
Registered: ‎04-28-2012
My Device: na
My Carrier: na
Accepted Solution

Implementing collapsible list, Cannot layout Field

Hi,

I'm implementing collapsible list using managers and field:

- When the cell is expanded, a data provider returns a list of fields to be added as child cells, and they are inserted to the vertical field manager.

- When the cell is collapsed, the child fields are removed from the vertical manager.

- The data provider is fetching the field properties from the web, so it is an asychronous process

 

Every thing is working fine except:

- When moving to next screen and go back nad trying to expand, collapse cells, the JDE console says:

WARNING Cannot layot field, insufficient height or width

 And the new fields are added to te manager but not drawn on the screen

 

Please Help

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Implementing collapsible list, Cannot layout Field

Welcome to the forums.

 

My experience with this message is that it tells it like it is.  If you have specified a Manager and fixed its size, or fixed a Field size, then you can see this.

 

I have never looked seriously at a problem like this because when I have had these problem, there was a clear issue with the Manager/Fields involved.  From memory (which is not reliable) the height usually was set to 0. 

 

Anyway without looking at your code  think this is going to be difficult for us to help you with.  And unfortunately, the best person to help you is probably yourself since you know what the code is doing and you have all the classes involved.  So if you need us to look at it, you might need to create a standalone Screen and Manager that has this problem, so that you can give us the code to look at and run ourselves. 

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Implementing collapsible list, Cannot layout Field

Make sure you add your collapsible list to a vertically scrolling manager.

 

Built-in managers (such as VerticalFieldManager) all treat VERTICAL_SCROLL flag in two ways:

1) They enable vertical scrolling so that the manager can change its vertical scrolling position

2) They give their children almost infinite available total height (0x3FFFFFFF, to be presize) during layout

 

If you are making your own manager, make sure you mimick the second part of it. And make sure you invoke super(VERTICAL_SCROLL ...) as the first part of its constructor to address the first part.

 

If you make your own fields, make sure you grab only as much height as you need and not more. For example, the following code in a custom Field

protected void layout(int maxWidth, int maxHeight) {
  ...
  setExtent(maxWidth, maxHeight);
}

 will take the rest or the Manager's remaining space and leave 0 as the maximum height for the rest of the fields. Make sure you properly calculate the Field's necessary height and set its extent properly.

 

There are many more possible small mistakes that will lead to this error - I've pointed out a couple of immediately obvious ones.

 

Good luck!

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 14
Registered: ‎04-28-2012
My Device: na
My Carrier: na

Re: Implementing collapsible list, Cannot layout Field

Thanks a lot,

Sorry for late reply cos I was in vacation.

My problem is solved without any changes to the UI code (my managers already had vertical scroll properties set).

The problem was related to the network operation and listeners.

Sorry for the confusion.

Although every thing is fine, but I'm still getting the warnings and I don't know why.

 

Thanks again.