03-27-2009 11:47 PM - edited 03-27-2009 11:51 PM
Exception detail is "Field is not a child of this manager."
Scenario: I've subclassed MainScreen, and overridden sublayout(). Exception is thrown in my sublayout(). Relevant code ...
super( NO_VERTICAL_SCROLL | DEFAULT_CLOSE );
_hdr = new MyHeader();
protected void sublayout(int mw, int mh)
super.sublayout( mw, mh);
layoutChild(_hdr, mw, 24);
setPositionChild(_hdr, 0, 0);
The exception confuses me greatly. I called add(_hdr) on my field up in this screen's constructor. And yet it tells me it is not a child of the manager. How can this be?
Thanks for any thoughts.
Platform: JDE 4.2.1
Solved! Go to Solution.
03-28-2009 02:48 PM
Can't really help you sorry, but I believe MainScreen actually has three Managers associated, one each for the title, body and status areas. I'm not sure how it manages sublayout in this case.
Perhaps you could add _hdr to your own manager, which has sublayout overridden?
03-28-2009 09:42 PM
Yeah, I think you are right.
I tried MainScreen.getMainManager().add(), FullScreen.getManager().add(), etc. All with no luck. It seems that even those screen classes look and smell like Managers and Fields, they really aren't. At least in the sense that you can't override sublayout.
Indeed, creating a manager, overriding its sublayout(), and adding the manager to the screen works fine.
12-09-2009 03:55 AM
I had a similar problem.
I had to add another manager in the middle to control the layout. The screen has only one control - myManager which all oter control are being added to it.
MyManager is implementing sublayout
12-13-2009 06:18 PM
Here is an example of this solution: http://www.thinkingblackberry.com/archives/188
The code of two (2) examples files, are pasted here:
FILE #1: ChatLayoutManager.java
FILE #2: ChatScreen.java