|
|
08-07-2007, 02:03 AM
|
#1
|
Knows Where the Search Button Is
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
|
Formating HorizontalFieldManager
Please Login to Remove!
I'm writting an address book and would like to display a title on the top of the screen. The title should be from style:
|Address Book (Bitmap)|
where "Address Book" should remain on the left and the Bitmap on the right side of the screen. Somehow i don't get it working right.
Here is the code i tried.
Code:
HorizontalFieldManager topManager = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
VerticalFieldManager titleManager = new VerticalFieldManager(VerticalFieldManager.FIELD_LEFT);
VerticalFieldManager logoManager = new VerticalFieldManager(VerticalFieldManager.FIELD_RIGHT);
LabelField title = new LabelField("Title", LabelField.FIELD_LEFT);
BitmapField logo = new BitmapField(Bitmap, BitmapField.FIELD_RIGHT);
titleManager.add(title);
logoManager.add(logo);
topManager.add(titleManager);
topManager.add(logoManager);
myScreen.setTitle(topManager);
I would appreciate some help and suggestions.
|
Offline
|
|
08-07-2007, 09:06 AM
|
#2
|
Talking BlackBerry Encyclopedia
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
|
obvious question but have you tried just using one horizontal field manager, with USE_ALL_WIDTH and NO_HORIZONTAL_SCROLL and doing without the Vertical Field Managers?
|
Offline
|
|
08-07-2007, 10:03 AM
|
#3
|
Knows Where the Search Button Is
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
|
yeah i have. to get absolutely sure i tried again after your post . doesn't work. that's the reason why i initially came to the idea of using two Managers and place them on the left and on the right side off the screen.
so i'm open for other suggestions - i would be grateful if somebody could get this to work.
|
Offline
|
|
08-08-2007, 03:08 AM
|
#4
|
Thumbs Must Hurt
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
|
Hi ,
Im not sure wat is going wrong with your program or the Api behaves like this manner. How is ur fields get Displayed.. I hope the right alignment is causing some problem.
Instead of using two seperate managers and adding these to another manager create your own manager and add the fields to it.
Use can place the fields at your desired location.
Tat will pretty solve your problem.
|
Offline
|
|
08-08-2007, 06:16 AM
|
#5
|
Knows Where the Search Button Is
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
|
I'm well aware of the possibility to extend a FieldManager to MyOwnFieldManager . I have done that for painting the background with a Bitmap.
But i don't see how this should solve my problem.
As you mentionend above the problem with my app is, that the Bitmap is not right aligned, but simply added to the FieldManager. So the title and the Bitmap are squeezed together on the left side off the screen.
If you know how to override the FieldManagers methods or constructor to allow proper alignment, please post the short code snippet here.
|
Offline
|
|
08-08-2007, 11:11 PM
|
#6
|
Thumbs Must Hurt
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
|
Hi,
If you try to add a empty label field between the title and bitmap.. I think it is a simple and silly approach but i hope it will satisfy your needs.
labelField = new LabelField(" ");
and override the labelfield getPrefferedWidth method if needed.
|
Offline
|
|
08-08-2007, 11:22 PM
|
#7
|
Thumbs Must Hurt
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
|
Hi,
Over ride this method in Manager
Define the array X position and y postion where fields to locate.
protected void sublayout( int width, int height )
{
int num = getFieldCount();
for( int i = 0; i < num; i++ )
{
Field field = getField( i );
setPositionChild(field,arrayX[i],arrayY[i]);
layoutChild(field, width, height); //lay out the field
}//for
setExtent( width, height );
}
|
Offline
|
|
08-09-2007, 01:32 AM
|
#8
|
Knows Where the Search Button Is
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
|
Thank you very much for the nice workaround. This will perfectly suit my needs. I have to keep the the lenght of the empty label field dynamic, because i'm going to deploy my application on different BB models and they vary in screen size.
But i think this can be done with getScreenWidth() and use a defined percentage for the empty labelfield.
Thanks again for helping
|
Offline
|
|
08-11-2007, 01:21 PM
|
#9
|
Thumbs Must Hurt
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
|
Maybe a lazier way to do it?
Hi folks,
I think I've found a slightly lazier way to do it.
I tried combining tschiefer's and bemshaswing's ideas. Together, they seem to work
I noticed that the USE_ALL_WIDTH needs to go in the second VerticalFieldManager.
(In my code here, I use a ButtonField instead of a BitmapField, but it shouldn't make any difference.):
Code:
private ButtonField btnBack = new ButtonField( "BACK", ButtonField.FIELD_RIGHT);
...
HorizontalFieldManager mgr0 = new HorizontalFieldManager();
VerticalFieldManager mgr0A = new VerticalFieldManager();
VerticalFieldManager mgr0B = new VerticalFieldManager( Manager.USE_ALL_WIDTH);
mgr0A.add( lblTitle);
mgr0B.add( btnBack );
mgr0.add( mgr0A);
mgr0.add( mgr0B);
add( mgr0);
Hope this might be helpful,
Mike
Last edited by bbCincinnati; 08-11-2007 at 01:22 PM..
Reason: clarification
|
Offline
|
|
08-13-2007, 08:24 AM
|
#10
|
Knows Where the Search Button Is
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
|
Very nice!
|
Offline
|
|
08-13-2007, 10:17 AM
|
#11
|
Thumbs Must Hurt
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
|
Thx
|
Offline
|
|
08-14-2007, 07:31 AM
|
#12
|
Thumbs Must Hurt
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
|
Hi
I tried the above code,but this is the display i am getting. I want the labels on the same line.Wht am i doing wrong?? . The image has been attached.
Code:
class TitleTest extends MainScreen {
HorizontalFieldManager hfmTitle ;
VerticalFieldManager vfmleft, vfmright;
LabelField lLest, lRight;
TitleTest() {
hfmTitle = new HorizontalFieldManager();
vfmleft = new VerticalFieldManager();
vfmright = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH);
lLest = new LabelField("Hi");
lRight = new LabelField("Hello", LabelField.FIELD_RIGHT);
vfmleft.add(lLest);
vfmright.add(lRight);
hfmTitle.add(vfmleft);
vfmleft.add(vfmright);
setTitle(hfmTitle);
}
}
__________________
Thanks
Meenal
|
Offline
|
|
08-14-2007, 07:51 AM
|
#13
|
Thumbs Must Hurt
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
|
Hi Meenal,
Try with the following code:
Code:
HorizontalFieldManager hfmTitle = new HorizontalFieldManager();
VerticalFieldManager vfmleft = new VerticalFieldManager();
VerticalFieldManager vfmright = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH);
LabelField lLest = new LabelField("Hi", LabelField.FIELD_LEFT);
LabelField lRight = new LabelField("Hello", BitmapField.FIELD_RIGHT);
vfmleft.add(lLest);
vfmright.add(lRight);
hfmTitle.add(vfmleft);
hfmTitle.add(vfmright);
setTitle(hfmTitle);
Hope this will point to your interest!
Cheers,
ARIF
Last edited by arifzaman; 08-16-2007 at 12:48 AM..
|
Offline
|
|
08-14-2007, 08:15 AM
|
#14
|
Thumbs Must Hurt
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
|
Thanks
__________________
Thanks
Meenal
|
Offline
|
|
11-15-2007, 03:42 PM
|
#15
|
Knows Where the Search Button Is
Join Date: Sep 2007
Model: 8830
PIN: N/A
Carrier: Verizon
Posts: 24
|
Thanks for the fix - this saved me a lot of hair-pulling. Why USE_ALL_WIDTH and Field.FIELD_RIGHT don't work together in a HorizontalFieldManager, I will never understand.
|
Offline
|
|
07-30-2008, 02:17 AM
|
#16
|
New Member
Join Date: Jul 2008
Location: Kochin
Model: 8800
PIN: N/A
Carrier: Airtel
Posts: 6
|
Try out like this , I have seeen that Its working with radiobuttonfields
Code:
HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager();
RadioButtonGroup rbg = new RadioButtonGroup();
RadioButtonField radioButtons[] = {
new RadioButtonField("", rbg, false, RadioButtonField.NO_USE_ALL_WIDTH),
new RadioButtonField("", rbg, false, RadioButtonField.NO_USE_ALL_WIDTH),
new RadioButtonField("", rbg, false, RadioButtonField.NO_USE_ALL_WIDTH),
new RadioButtonField("", rbg, false, RadioButtonField.NO_USE_ALL_WIDTH),
new RadioButtonField("", rbg, false, RadioButtonField.NO_USE_ALL_WIDTH) };
for (int i = 0; i < 5; i++) {
horizontalFieldManager.add(radioButtons[i]);
}
add( horizontalFieldManager );
__________________
Praveen K
|
Offline
|
|
02-20-2009, 06:24 PM
|
#17
|
New Member
Join Date: Feb 2009
Model: 7100T
PIN: N/A
Carrier: ATT
Posts: 1
|
I have a very similar question regarding the HoriontalFieldManager,
I'm trying to set up a search bar with this format
|logo|----------search_bar------------|button|
Where the logo, and button have set sizes, and the search bar fills the remaining space.
Previously I was working on android and this was easily achieved by setting the layout weight to a higher priority on the "non-filling" items.
However I can't figure out how to do this with the BB HorizontalFieldManager:
I add the logo
I add the search bar
I add the button
The logo shows up fine where I want it because it's the first thing I add to the manager, but then the search bar fills the remainder of the screen and there is no room left for my button. So it just gets pushed off the other edge where it can't be seen.
There must be a right way to do this. Am I missing something?
the code for my search bar:
Code:
public SearchBar(FieldChangeListener listener) {
super(Manager.USE_ALL_WIDTH);
this.bitmapField = new BitmapField(Bitmap.getBitmapResource("main_logo.png"));
editField = new EditField("", "", 75, EditField.NO_NEWLINE);
this.myButton = new myButton();
/*******************/
XYEdges xyedges = new XYEdges(5,5,5,5);
editField.setMargin(10, 10, 10, 10);//top,rt,btm,lft
editField.setBorder(BorderFactory.createBevelBorder(xyedges));
/*******************/
editField.setChangeListener(listener);
add(bitmapField);
add(editField);
add(myButton);
}
the code for my button:
Code:
public myButton() {
super(Manager.FIELD_RIGHT);
bitmapField = new BitmapField(Bitmap.getBitmapResource("button.png"));
add(bitmapField);
}
|
Offline
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
MSA 10116926 Altair 5X Gas Detector Industrial Kit - LEL, O2, CO, H2S $1500.00
MSA 10074137 Oxygen Altair Pro Single Gas Detector (O2) $200.00
MSA 10042621 Altair 5X Sampling Probe Straight Air-Line 1' Color Black (E2) $295.00
MSA altair 4X gas Monitor detector, O2,H2S,CO,LEL Charger calibrated $450.00
Altair WBS-202 Dual channel wireless intercom base station $1350.00
MSA Altair 5X Gas Detector Industrial Kit 10116926 - LEL, O2, CO, H2S $1899.00
|
|