BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-07-2007, 02:03 AM   #1
tschiefer
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Default 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  
Old 08-07-2007, 09:06 AM   #2
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Default

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  
Old 08-07-2007, 10:03 AM   #3
tschiefer
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Default

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  
Old 08-08-2007, 03:08 AM   #4
Rose
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Default

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  
Old 08-08-2007, 06:16 AM   #5
tschiefer
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Default

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  
Old 08-08-2007, 11:11 PM   #6
Rose
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Default

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  
Old 08-08-2007, 11:22 PM   #7
Rose
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Default

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  
Old 08-09-2007, 01:32 AM   #8
tschiefer
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Default

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  
Old 08-11-2007, 01:21 PM   #9
bbCincinnati
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Smile 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  
Old 08-13-2007, 08:24 AM   #10
tschiefer
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Default

Very nice!
Offline  
Old 08-13-2007, 10:17 AM   #11
bbCincinnati
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Default

Thx
Offline  
Old 08-14-2007, 07:31 AM   #12
Meenal
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Default

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);
    }
}
Attached Images
File Type: png 8800.png (1.5 KB, 25 views)
__________________
Thanks
Meenal
Offline  
Old 08-14-2007, 07:51 AM   #13
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Default

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  
Old 08-14-2007, 08:15 AM   #14
Meenal
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Default

Thanks
__________________
Thanks
Meenal
Offline  
Old 11-15-2007, 03:42 PM   #15
sn0wshrew
Knows Where the Search Button Is
 
Join Date: Sep 2007
Model: 8830
PIN: N/A
Carrier: Verizon
Posts: 24
Default

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  
Old 07-30-2008, 02:17 AM   #16
praveen@unispeck.com
New Member
 
praveen@unispeck.com's Avatar
 
Join Date: Jul 2008
Location: Kochin
Model: 8800
PIN: N/A
Carrier: Airtel
Posts: 6
Default

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  
Old 02-20-2009, 06:24 PM   #17
bluehex
New Member
 
Join Date: Feb 2009
Model: 7100T
PIN: N/A
Carrier: ATT
Posts: 1
Default

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  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


1pcs used TSXMFPP128K Memory Card picture

1pcs used TSXMFPP128K Memory Card

$175.00



2021-2022 AB 1400 1766MM1 Memory Module 1766-MM1 in Stock picture

2021-2022 AB 1400 1766MM1 Memory Module 1766-MM1 in Stock

$122.33



Desktop Memory Case Tray Case for PC DDR DRAM RAM DIMM Modules - 2 fits 100 New picture

Desktop Memory Case Tray Case for PC DDR DRAM RAM DIMM Modules - 2 fits 100 New

$20.50



2 - RAM DRAM Tray-Container Box For Server PC Memory DIMM Modules - Fits 100 NEW picture

2 - RAM DRAM Tray-Container Box For Server PC Memory DIMM Modules - Fits 100 NEW

$21.90



Argolladora We R Memory Keepers Heidi Swapp Cinch Binding Machine 71050-9 by AC picture

Argolladora We R Memory Keepers Heidi Swapp Cinch Binding Machine 71050-9 by AC

$79.99



WIFI Audio Voice Recorder Live Real-Time Audio Thru App | Charger & 32GB SD Card picture

WIFI Audio Voice Recorder Live Real-Time Audio Thru App | Charger & 32GB SD Card

$129.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.