aligning HorizontalFieldManager to the bottom of the Screen - blackberry

i am having 4 ButtonField and i want to align all the buttons horizontally. for that i am using HorizontalFieldManager and assigning Field.FIELD_BOTTOM for putting all the button field to the button of the screen. but its not working fine. i don't no what is wrong with it

Try to set USE_ALL_HEIGHT style in manager constructor:
class MenuScreen extends MainScreen {
public MenuScreen() {
super(DEFAULT_CLOSE);
HorizontalFieldManager manager =
new HorizontalFieldManager(FIELD_BOTTOM|USE_ALL_HEIGHT);
add(manager);
manager.add(new ButtonField("1", FIELD_BOTTOM));
manager.add(new ButtonField("2", FIELD_BOTTOM));
manager.add(new ButtonField("3", FIELD_BOTTOM));
manager.add(new ButtonField("4", FIELD_BOTTOM));
}
}
alt text http://img412.imageshack.us/img412/8776/managerg.jpg

Related

Scrolling issue on Vaadin 21 and ApplicationLayout

I have a strange problem with the application layout and views which need to be scrolled:
If I create an application with the default App Layout, the drawer toggle is on the top and I add a VerticalLayout with fullsize as view everything is working as expected. But if the vertical content exceeded the height of the browser window (even if I put this content into a scroller), the whole view get scrolled and disappears behind the toggle until the height of the toggle is reached, than scrolling stops.
It seams that setHeight(100, Unit.Percentage) does not considers the height of the toggle.
Has someone a similiar problem?
Edit
Put the following code as a view into an AppLayout and open this on your mobile device e.g. iPhone and you will see the vertical scroller:
#Route(value = "application/test", layout = ApplicationLayout.class)
#PageTitle("Test")
#RolesAllowed({"ROLE_NEWSLETTER_ADMIN", "ROLE_ORGANIZATION_ADMIN"})
public class TestView extends VerticalLayout implements BeforeEnterObserver {
private MenuBar menu;
private Grid<Person> grid;
private Label footerLabel;
public TestView() {
this.setSizeFull();
menu = new MenuBar();
menu.addItem("New");
menu.addItem("Edit");
menu.addItem("Delete");
this.add(menu);
grid = new Grid<>(Person.class);
this.add(grid);
this.expand(grid);
footerLabel = new Label("Number of objetcs: #");
this.add(footerLabel);
}
#Override
public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {
}
}
AppLayout:
public class ApplicationLayout extends AppLayout implements AfterNavigationObserver {
private ApplicationService applicationService;
private H1 headerTitle;
public ApplicationLayout(ApplicationService applicationService) {
this.applicationService = applicationService;
createHeader();
createDrawer();
this.setPrimarySection(Section.DRAWER);
}
private void createHeader() {
// Define the header
HorizontalLayout header = new Header(new H1("Header"));
addToNavbar(header);
}
private void createDrawer() {
....
}
}
It seams that setHeight(100, Unit.Percentage) does not considers the height of the toggle.
Correct. The 100% is the size of the view port. So if you have e.g. the following
VerticalLayout vLayout = new VerticalLayout();
Button button = new Button();
button.setHeight(50, Unit.Pixels);
HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setHeight(100, Unit.Percentage);
vLayout.add(button,hLayout);
This will produce something where vLayout height is more that viewport height and scroll bar emerges. Instead you should do.
VerticalLayout vLayout = new VerticalLayout();
Button button = new Button();
button.setHeight(50, Unit.Pixels);
HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setHeight(200, Unit.Pixels);
vLayout.add(button,hLayout);
vLayout.expand(hLayout); // or vLayout.setFlexGrow(1.0d, hLayout);

create popup screen in blackBerry

I want to create a popup screen in BlackBerry like the screen appear on long click (see the picture)
My screen contain 3 items
image description
image description
image description
Can any one help me by an example or link to do this popup?
Use the below code and call the GetPopup wherever you want to show the pop up screen
final class Getpopup extends PopupScreen
{
EditField edf;
AutoTextEditField edf1;
HorizontalFieldManager hfm;
public Getpopup()
{
super( new VerticalFieldManager());
LabelField lf = new LabelField("Contact Info", LabelField.FIELD_HCENTER);
SeparatorField sf = new SeparatorField();
edf1= new AutoTextEditField("Name:","" ,20,EditField.NO_NEWLINE);
edf = new EditField("Number:",ThirdScreen.get3);
edf.setEditable(false);
VerticalFieldManager vfm =new VerticalFieldManager(VerticalFieldManager.FIELD_HCENTER);
hfm=new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
ButtonField bf1 = new ButtonField("Save", ButtonField.FIELD_HCENTER);
ButtonField bf2 = new ButtonField("Cancel", ButtonField.FIELD_HCENTER);
hfm.add(bf1);
hfm.add(bf2);
vfm.add(lf);
vfm.add(sf);
vfm.add(edf1);
vfm.add(edf);
vfm.add(hfm);
add(vfm);
}
}
Find the code here to create creating-borderless-transparent-popup screen in blackberry
If your looking for custmizing the Buttons as appeared in image then visit custom-image-buttonfield-in-blackberry
You have to make use of GridFieldManager.java for the layout you have used, Also you can customize your own layout.
Create a PopupDialog class which extends Dialog and then in the constructor, add the Buttons. If you would like your buttons to look like the above image, extend a field or button field and in paint method, draw the button and then the button text below the button. Add this custom button control in the PopupDialog.

need help with Field Managers Blackberry

I keep getting an IllegalArgumentException and nothing shows on the BlackBerry simulator when I run this code. What could be wrong with it?
public MyScreen()
{
// Set the displayed title of the screen and add the weather icons
setTitle("PixWeather");
cityField = new LabelField("Queensland", Field.FIELD_LEFT);
tempField = new LabelField("17", Field.FIELD_RIGHT);
condField = new LabelField("sunny",Field.FIELD_RIGHT);
weather_icon = Bitmap.getBitmapResource("sun_icon.png");
bitmapField = new BitmapField(weather_icon, Field.FIELD_LEFT);
VerticalFieldManager vfield = new VerticalFieldManager();
HorizontalFieldManager hfield1 = new HorizontalFieldManager();
hfield1.add(cityField);
hfield1.add(tempField);
HorizontalFieldManager hfield2 = new HorizontalFieldManager();
hfield2.add(bitmapField);
hfield2.add(condField);
vfield.add(hfield1);
vfield.add(hfield2);
}
The IllegalArgumentException could be unrelated, but nothing is showing up on your screen because you didn't add anything to your screen.
You need to add the vfield to the screen itself. Add the following line:
add(vfield);

Trying to draw a bitmap on blackberry

I'm just learing how to program the blackberry and trying to display a bitmap on the screen, here is the code:
public MyScreen()
{
// Set the displayed title of the screen
setTitle("MyTitle2");
LabelField lb = new LabelField("hello ted2");
add(lb);
Bitmap logoBitmap = Bitmap.getBitmapResource("res/icon2.png");
BitmapField fd= new BitmapField(logoBitmap, Field.FIELD_HCENTER);
add(fd);
}
The label is drawn but not the bitmap.
Your path is wrong, copy the image into /res/img. To retrieve that, use the file name only.
Bitmap logoBitmap = Bitmap.getBitmapResource("icon2.png");
I think you need to put the two fields into a VerticalFieldManager:
public MyScreen()
{
VerticalFieldManager vfm = new VerticalFieldManager();
// Set the displayed title of the screen
setTitle("MyTitle2");
LabelField lb = new LabelField("hello ted2");
vfm.add(lb);
Bitmap logoBitmap = Bitmap.getBitmapResource("res/icon2.png");
BitmapField fd= new BitmapField(logoBitmap);
vfm.add(fd);
add(vfm);
}

How to create VerticalField Manager in Blackberry?

I want to know how to create VerticalFieldManager and i want to add some components also.
Couple of options:
A basic vertical field manager:
VerticalFieldManager vfm = new VerticalFieldManager();
// add your fields
vfm.add(new LabelField("First Label");
vfm.add(new LabelField("Second Label");
// etc
// then don't forget to add your vertical field manager to your screen
// assuming you're in the screen's constructor:
add(vfm);
The labels will appear top to bottom in the order you add them.
If you're going to add more fields than will fit vertically on a screen, you may want to make your manager scrollable:
VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
// the rest is the same as above
You can omit VERTICAL_SCROLLBAR if you don't want to see the up/down arrows.
But finally, if you just want a bunch of fields vertically on a screen, MainScreen by default uses a scrolling VerticalFieldManager as its delegate so you can just add fields directly and get the same effect:
class MyScreen extends MainScreen {
public MyScreen() {
add(new LabelField("Label 1");
add(new LabelField("Label 2");
// etc
}
}
Creation :
VerticalFieldManager vfm = new VerticalFieldManager();
Add different fields to it:
vfm.add(somefield);

Resources