BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-07-2007, 03:03 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 10:06 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 11:03 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 04:08 AM   #4 (permalink)
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 07:16 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
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-09-2007, 12:11 AM   #6 (permalink)
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts
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-09-2007, 12:22 AM   #7 (permalink)
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 02:32 AM   #8 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 02:21 PM   #9 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 02:22 PM. Reason: clarification
Offline  
Old 08-13-2007, 09:24 AM   #10 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Very nice!
Offline  
Old 08-13-2007, 11:17 AM   #11 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thx
Offline  
Old 08-14-2007, 08:31 AM   #12 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 08:51 AM   #13 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 01:48 AM.
Offline  
Old 08-14-2007, 09:15 AM   #14 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks
__________________
Thanks
Meenal
Offline  
Old 11-15-2007, 03:42 PM   #15 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2007
Model: 8830
PIN: N/A
Carrier: Verizon
Posts: 24
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 03:17 AM   #16 (permalink)
New Member
 
praveen@unispeck.com's Avatar
 
Join Date: Jul 2008
Location: Kochin
Model: 8800
PIN: N/A
Carrier: Airtel
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
New Member
 
Join Date: Feb 2009
Model: 7100T
PIN: N/A
Carrier: ATT
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
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


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





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