02-26-2011 01:13 AM
hello
can anybody tell me how i can layout my screen using HorizonatalFieldManager and VerticalFieldManager.
i want to display image and text like below way:
image1 text1
image2 text2
image3 text3
i try more time but it can throw unacaught exception,
can u give me any example like it.
i also store default image where url not contain any image
it work with FlowField but it show like below:
image1 text1 image2 text2
image3 text3 image4 text4
i dont want this ,i like to show such as first mention.
now i work in bb jde 4.6 and i want support it 4.6 and later
Solved! Go to Solution.
02-26-2011 01:57 AM
It is very easy task.
You have to take one Vertical FieldManager then insert that VErticalFieldManager in a Screen.
Then take 3 Horizontal fieldManager one for each row so you can create 3 rows.
Then add Image1 and text1 in horizontalfieldManager1 like that for second and third row then add that 3 horizontalFields in verticalField manager..
02-26-2011 02:08 AM
i take images and text dynamically from url and there are ten images and texts,
i try like this,for example
for(i=0;i<titleList.getLength();i++)
{
hfm.add(new Label(data));
hfm.add(bf);
vfm.add(hfm);
}
add(vfm);
it's not real code ,but logic like it.
it show me uncaught exception.
here hfm ->horizonal
and vfm->vertical
bf->bitmapfield
data->text
02-26-2011 10:26 AM
1) Are you getting IllegalStateException? This is normal if you are trying to manipulate anything on the Screen stack from a non-event thread. If it is another exception, post the details here.
2) For your layout you need a separate HFM for each text-image pair. Like this:
VerticalFieldManager vfm = new VerticalFieldManager(VERTICAL_SCROLL ...);
for (i = 0; i < length; ++i) {
HorizontalFieldManager hfm = new HorizontalFieldManager();
hfm.add(new Label(text[i]));
hfm.add(new BitmapField(image[i]));
vfm.add(hfm);
}
add(vfm);
If you are adding all this to a MainScreen with "no arguments" constructor (it has VERTICAL_SCROLL enabled by default), you can skip vfm and add your HFMs directly to the screen.
02-27-2011 11:55 PM
thank u very much,
i solve my problem according ur guidence.
actually i do not declare Horizontalfield every time,
i just use globaly it .
02-28-2011 12:42 AM
The point is not to declare HFM every time (even though I did that in the loop) - the point is to create a new one for each "row" (new HorizontalFieldManager()).
02-28-2011 12:49 AM
thanks,
i have one problem about to put seperator betwwen two row.
and also require to put space between image and text horizontally
example;
------------------
image1 text1
--------------------
image2 text2
-------------------
when i add separatorField in vertaiacalfieldmanager it show me error like,
u don't add void property in verticalField manager.
help me please.
02-28-2011 01:40 AM
Hi there,
Inorder to display a separator between the rows use SepatatorFiled in the ' for ' loop and
for maintaining distance between the fields in rows use setMargin and setPadding methods.
May be below code 'll b helpful.
VerticalFieldManager _vfm = new VerticalFieldManager(VERTICAL_SCROLL);
for (i = 0; i < length; ++i) {
HorizontalFieldManager _hfm = new HorizontalFieldManager();
_hfm.add(new LabelField(text[i]));
_hfm.add(new BitmapField(image[i]));
_hfm.setPadding(9,9,9,9);
_hfm.setMargin(9,9,9,9);
vfm.add(_hfm);
vfm.add(new SeparatorField());
}
add(vfm);
use setPadding and setMarging method with fields and managers effectively inorder to achieve ur
requirements.
regards,
Saran.
Give kudos if this post is helpful..........![]()
02-28-2011 01:41 AM
For Space between LabelField & Image, you can use either setPadding() method or add a LabelField with text as ' '(some spaces) .
And for Separators each time you have to create new instance of SeparatorField and add it to the VerticalFieldManager.
02-28-2011 01:51 AM
thanks it work.