BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/index.php)
-   Developer Forum (http://www.blackberryforums.com/forumdisplay.php?f=15)
-   -   split screen in two (http://www.blackberryforums.com/showthread.php?t=94038)

genvej 09-07-2007 01:53 AM

split screen in two
 
Hi.

Is there anyway i can split my screen in two so my components will always have the same location on screen??



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

ObjectChoiceField

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

button

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

My problem is that my ObjectChoiceField text varies in size, which makes my button bounce up and down for each entry

dropDown=new ObjectChoiceField("choose a plant: ",choiceItems,0,ObjectChoiceField.FIELD_LEFT);

arifzaman 09-08-2007 10:43 PM

Hi genvej,

Use "Manager" class to split your screen.

Cheers,
ARIF

genvej 09-12-2007 02:53 AM

well thats what i originally though i would do, however it doesnt seem to work for me. My problem is that sometime my choiceItems is really long in size and therefore makes my stuff in the next manager to jump up and down:cry:

could u tell me what im doing wrong here?

Quote:

VerticalFieldManager vfm=new VerticalFieldManager(Manager.VERTICAL_SCROLL);
dropDown=new ObjectChoiceField("vælg en plan: ",choiceItems,0,ObjectChoiceField.FIELD_LEFT);
vfm.add(new LabelField(""));
vfm.add(dropDown);
vfm.add(new LabelField(""));
add(vfm);
Bitmap DocBitmap=Bitmap.getBitmapResource("100Dossier.jpg ");
BitmapField DocBitmapField=new BitmapField(DocBitmap,BitmapField.FIELD_RIGHT);


add(new LabelField(""));
FieldListener sendListener = new FieldListener();
ButtonField sendButton = new ButtonField("Bekræft",ButtonField.CONSUME_CLICK);
sendButton.setChangeListener(sendListener);

HorizontalFieldManager hfm=new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
hfm.add(DocBitmapField);
hfm.add(sendButton);

add(hfm);



bemshaswing 09-12-2007 10:07 AM

You seem to be trying to use a vertical and a horizontal field managers to split. If you want to do a vertical split screen as in

-------
|Top Half|
|Bottom Half|
-------

create one vertical field manager and add two horizontals
if you want to do it like:
-------------------
|Left Half|Right Half|
|Left Half|Right Half|
-------------------
use one horizontal and two vertical.

Note that in your example you are adding vfm and hfm directly to the screen. You'll have to create a manager in the above examples and then,
[superManager].add(submanager);
[superManager].add(submanager);

genvej 09-12-2007 12:50 PM

Im absolutely positive your right in this matter... however im not smart enough to make it work. Do you by any chance have a sample code?

bemshaswing 09-12-2007 02:13 PM

Code:

VerticalFieldManager vfm=new VerticalFieldManager(Manager.VERTICAL_SCROLL);

Bitmap DocBitmap=Bitmap.getBitmapResource("100Dossier.jpg ");
BitmapField DocBitmapField=new BitmapField(DocBitmap,BitmapField.FIELD_RIGHT);

HorizontalFieldManager left =new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
left.add(DocBitmapField);

HorizontalFieldManager right  =new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
right.add(sendButton);

vfm.add(left);
vfm.add(right);

add(vfm);

i haven't tested this but this is more or less what you want for a split left right. note you may have to create custom horizontal managers and restrict the width as regardless of Manager.USE_ALL_WIDTH being part of the style, sometimes it tries to fill the screen with them.

tweak it to your needs and try it out.

genvej 09-12-2007 03:44 PM

Quote:

Originally Posted by bemshaswing (Post 664749)
Code:

VerticalFieldManager vfm=new VerticalFieldManager(Manager.VERTICAL_SCROLL);

Bitmap DocBitmap=Bitmap.getBitmapResource("100Dossier.jpg ");
BitmapField DocBitmapField=new BitmapField(DocBitmap,BitmapField.FIELD_RIGHT);

HorizontalFieldManager left =new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
left.add(DocBitmapField);

HorizontalFieldManager right  =new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
right.add(sendButton);

vfm.add(left);
vfm.add(right);

add(vfm);

i haven't tested this but this is more or less what you want for a split left right. note you may have to create custom horizontal managers and restrict the width as regardless of Manager.USE_ALL_WIDTH being part of the style, sometimes it tries to fill the screen with them.

tweak it to your needs and try it out.


Ur an ace.... got it:idea:

TheDoor 09-18-2007 05:12 PM

Quote:

Originally Posted by genvej (Post 664861)
Ur an ace.... got it:idea:

I use your solution to do the same thing:
I write this in the MainScreen constructor...

Code:

Manager mgrTitle = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
Manager mgrLeft = new VerticalFieldManager(Manager.VERTICAL_SCROLL);
Manager mgrRight = new VerticalFieldManager(Manager.VERTICAL_SCROLL);

mgrLeft.add(new LabelField("left", LabelField.FIELD_LEFT));
mgrRight.add(new LabelField("right", LabelField.FIELD_RIGHT));

mgrTitle.add(mgrLeft);
mgrTitle.add(mgrRight);

add(mgrTitle);

The result are:
--------------
|leftright |
--------------

The solution does not work for me!
What wrong with my code?

bemshaswing 09-19-2007 09:48 AM

what were you expecting?

simon.hain 09-19-2007 10:39 AM

you could use a fixed layout.
Extend Manager, give it arrays with coordinates and your fields and use it to place the components on specific coordinates.
Your button would be on the same place every time but if your ObjectChoiceField gets to big it will be overlapped.

HfM/VfM are good if you want to have your layout flexible, in your case a fixed layout would work better if i understood your request right.

gs
simon

youarenumber1 12-04-2008 06:26 PM

When using vertical custom layout manager, why scroll arrow don't appear? The following is my testing code, could anybody help me? I really appreciate...........


class Napolean extends UiApplication {


public static void main (String[] args)
{

Napolean theApp =new Napolean();
theApp.enterEventDispatcher();

}


public Napolean()
{





MainScreen myScreen = new MainScreen();

CustomManager_test Layout_test = new CustomManager_test();
for (int i=0; i<10; i++) {
ButtonField btn = new ButtonField( "test"+i);

Layout_test.add(btn);
}

myScreen.add(Layout_test);
pushScreen(myScreen);

}
}




class NP_RegisterScreen2 extends MainScreen {

NP_RegisterScreen2()
{
CustomManager_test Layout_test = new CustomManager_test();


MainScreen myScreen = new MainScreen();




for (int i=0; i<10; i++) {
ButtonField btn = new ButtonField( "test"+i);

Layout_test.add(btn);
}

myScreen.add(Layout_test);

}
}




class CustomManager_test extends Manager
{

public CustomManager_test()
{
super( Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR );


}


protected void sublayout(int mywidth, int myheight)
{

Field field;
int numberoofFields =getFieldCount();
int column_no=3;


int x=0;
int y=0;
for (int lcv = 0; lcv < numberoofFields; lcv++)
{
field = getField(lcv);
setPositionChild(field, x, y);
layoutChild(field, mywidth , myheight);
x=0;
y+=30;

}


setExtent(mywidth, 120);



}

public int getPreferredWidth()
{
int width=20;
return width;

}

public int getPreferredHeight()
{

int height = 230;
return height;

}


All times are GMT -5. The time now is 02:22 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.