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
Contributor
Benjen
Posts: 33
Registered: ‎05-12-2010
My Device: none

Setting the size of a custom field

Hello everyone,

 

I have searched these forums regarding my question but I guess I could not find anything truly satisfying, so I will expose my problem to you.

 

I am trying to make a screen where you would have a VerticalFieldManager that is fixed in height and scrollable. Underneath that screen should be a button but that is not the problem here.

 

I have seen many threads that state the setExtent and sublayout function, but they usually imply to extend the VerticalFieldManager, I understand why this is necessary but I do not really see how to do it.

 

Could anyone explain this to me?

 

Thanks a lot for your time, i won't forget to reward you with kudos.

Please use plain text.
Developer
simon_hain
Posts: 16,137
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Setting the size of a custom field

you have to overwrite the layout of the controlling manager. if your fixed-size vfm is added to a mainscreen directly you have to overwrite the layout of the mainscreen.

 

maybe this article helps you:

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800508/...

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
Benjen
Posts: 33
Registered: ‎05-12-2010
My Device: none

Re: Setting the size of a custom field

Thank you for the quick reply Simon, so I have tried implementing what I saw in the link and simplified it.

 

Before I show you the code, let me explain the way my different managers work, I have one for the screen of course (the main manager), then I would like to have this new custom fieldmanager to add to the main manager.

 

However now when I add something to the Custom Field nothing shows on the screen, i must have forgotten to put something in there, what could it be?

 

class CustomVFM extends VerticalFieldManager {

public CustomVFM() {
//construct a manager with vertical scrolling
super(VerticalFieldManager.VERTICAL_SCROLL);}
protected void sublayout(int width, int height) {
setExtent(300, 300);}};

I know my questions are kind of dumb but I really cannot say I "own" the subject.

Please use plain text.
Developer
simon_hain
Posts: 16,137
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Setting the size of a custom field

a manager is invisible, you have to add fields to it.

you can control the size of the field/manager either in the manager itself or in the outer manager, i would suggest to use the outer manager.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Setting the size of a custom field

First of all, this question is not dumb, it is excellent.  Limiting the size is something that RIM's native Managers lack, so you have to do it yourself somehow.

 

Having said that - you are on the right track with setExtent().  It is indeed done during layout() for Fields and sublayout() for Managers.  Just don't forget to call super.sublayout(width, height) before that - let the built-in VerticalFieldManager do the hard work of figuring out Field positions and its size, then override its setExtent() decision.  Also, you might want to leave that width alone - after super.sublayout your Width is already set, so setExtent(getWidth(), <your own height>) is probably better.

 

setExtent() sets the visible size of the Field/Manager, which tells the parent Manager how much room is left for other Fields and defines the maximum area the Field/Manager can paint.

 

setVirtualExtent() sets the full size of the Manager - you might see less than that (if Extent is smaller than VirtualExtent) but can scroll to other parts.  This is necessary for all devices but is especially crucial for touch-screen devices.  VerticalFieldManager with VERTICAL_SCROLL (as in your example) will set that properly for you (again referring to that super.sublayout above).  Once you go past built-in Managers and create your own custom ones, remember setVirtualExtent().

 

As for the Manager to actually display something - do as Simon says ("Simon says?"  Sounds familiar, even for a non-native English speaker like me) and add your fields to it.

----------------------------------------------------------
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.