BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-12-2009, 12:32 AM   #1 (permalink)
New Member
 
Join Date: Mar 2009
Model: BOLD
PIN: N/A
Carrier: 010
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Post how to align HorizonFieldManager including each Field components on the screen :)

Please Login to Remove!

help me
I was trying put HorizonFieldManager on the middle of screen horizontally.
but I couldn't


below is my source code. how to align HorizonFIeldManager on the middle.

please let me know



-----------------------------------------------------------------------



public class BBTest001 extends UiApplication{

public static void main(String[] ar){
BBTest001 theApp = new BBTest001();
MyScreen showString = new MyScreen();
theApp.pushScreen(showString);
theApp.enterEventDispatcher();

}

}

/**
* MainScreen
*/
class MyScreen extends MainScreen{
public MyScreen() {
drawScreen();
}

public void drawScreen(){
LabelField labelField = new LabelField("here is title", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH | LabelField.FIELD_HCENTER);
setTitle(labelField);

HorizontalFieldManager horizon = new HorizontalFieldManager(Field.FIELD_HCENTER);
Bitmap img = Bitmap.getBitmapResource("bulletSmallIcon.png");
BitmapField imgField = new BitmapField(img);

BasicEditField basic = new BasicEditField();

horizon.add(imgField);
horizon.add(basic);

add(horizon);
}
Offline  
Old 03-12-2009, 10:51 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

actually it is correctly alligned. The only thing is that your horizontal filed manager takes the whole width of the screen. This is because of the containing BasiceditField inside which takes the whole available space for it.

you can see it if you override the paint methods:

Code:
		HorizontalFieldManager horizon = new HorizontalFieldManager(Field.FIELD_HCENTER) {
			protected void paint(Graphics graphics)
			{
				graphics.setBackgroundColor(Color.LIGHTGREY);
				graphics.clear();

				super.paint(graphics);
			}
		};

...

		BasicEditField basic = new BasicEditField(){
			protected void paint(Graphics graphics)
			{
				graphics.setBackgroundColor(Color.DARKGRAY);
				graphics.clear();

				super.paint(graphics);
			}
		};
what you have to do is to limit the space for the BasicEditField by overriding the layout method.

Code:
		BasicEditField basic = new BasicEditField(){
			protected void layout(int width, int height)
			{
                                // e.g. limit to the half of available space 
				super.layout(width / 2, height);
			}
		};
__________________
Blessed is the end user who expects nothing, for he/she will not be disappointed. (Franklin's Rule)
Offline  
Old 03-15-2009, 10:37 AM   #3 (permalink)
New Member
 
Join Date: Mar 2009
Model: BOLD
PIN: N/A
Carrier: 010
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much Ivanov~~
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.