07-30-2010 02:54 AM
how to get value to controlling size inside manager?
i always get 0 value for getWidth and getHeight.
for example i have
HorizontalFieldManager hfm = new HorizontalFieldManager();
VerticalFieldManager vfm = new VerticalFieldManager();
i want to get the width and height of vfm so i can control the sublayout and setExtent
Solved! Go to Solution.
07-30-2010 02:58 AM
Will return the values of width and heifht of manager;
07-30-2010 03:09 AM
i tried to use that but still i got 0 value
is there any example for my case?
i want to set the width and height my manager that depends on the field inside it...
07-30-2010 03:36 AM
The way is you can extend your manager class and in sublayout()method .We can setposition of childs and setextent(width,height);
Next is adding null field(This is not preferrable).But we can set position as per our needs.
setMargin will also help you.
07-30-2010 05:58 AM
I think you are not clear on when getWidth, getHeight and subLayout are all used and how they relate to each other. Instead of trying to explain what you what using these method names, can you explain the effect you are trying to achieve. Use 'layman's terms, then we won't get confused. OK?
Note that until the Manager is layed out, it will not have a width or a height, so you might be in a circular situation when you are trying to calculate something that relies on something else that needs the value that you are calculating.
07-30-2010 11:20 AM
To elaborate a little on what Peter has said:
Your Manager's sublayout() is the method that sets its width and height (along with virtual width and virtual height, along with positions of its managed fields within the Manager, etc.). Before that, width and height are zeros. But when is it called?
sublayout() is called only when BlackBerry is ready to display a screen containing the manager, overall screen layout changes (say, you tilt your touchscreen device), something that changes the displayed fields (add, delete, insert, replace on an already visible manager) happens, a field needs to update its layout and requests the whole layout to be recalculated (say, you type enough text in a TextField to make it wrap to the next line) etc. It is a tool for the framework to let the Manager know how much room does it have and make it calculate and report its extent within those limits.
However, while you cannot rely on the getHeight and getWidth unless your Manager is displayed, you can have a rough estimate by using getPreferredHeight() and getPreferredWidth(). Ironically, the BB framework does not use those while laying out the screen - but all BlackBerry native Fields have some decent algorithms there, so you may find them useful.
Still, the main question is: what are you trying to achieve?
08-01-2010 12:36 PM
i'm trying to archieve the size value (width and height) inside the manager
LabelField item1 = new LabelField("test1"); LabelField item2 = new LabelField("test2"); LabelField item3 = new LabelField("test3"); HorizontalFieldManager hfm = new HorizontalFieldManager(); hfm.add(item1); hfm.add(item2); hfm.add(item3); add(hfm);
i want to know the width and height of item1,item2, and item3
so i can set the sublayout
08-01-2010 01:12 PM
I recommend that you review these two videos:
Then have a look at this:
The trick is what to do at this line:
y += ...;
Because you have asked the child to layout itself here:
layoutChild(field, width, height); //lay out the field
it should know how big it wants to be. So you can ask it how big it is
Does that help?
08-04-2010 04:57 AM
here is my case
i set the header and footer setExtent height = display.getHeight( )/5
and the body setExtent height = display.getHeight( )*3/5
so i will have a fixed layout.
but i have a problem with my list field (my list field not static/fixed, i got it from database, so i can't set the setExtent)
everytime scroll it down, at the end of line all my field and my body become blank (white)
i've tried by set the setExtent to a certain numbers for example 500
its work but if only my list field (data) is static.
sorry, i'm really bad explaining it