BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Align buttons in the bottom of the screen? (http://www.blackberryforums.com/developer-forum/212520-align-buttons-bottom-screen.html)

clavemartin 12-02-2009 05:31 AM

Align buttons in the bottom of the screen?
 
I have developed a home screen of my application using VerticalFieldManager and added a background image, label, rich text field etc. I am trying add three buttons now. I want to have three buttons such as "Add", "Edit" and "Delete" buttons in entirely bottom of the screen with the same size. But if i add buttons using HorizontalFieldManager and add to main manager, it shows all the buttons in the top (next line of whatever the contols thee in the top) and also button size varies. How do i create same size buttons and move only those buttons to the bottom of the screen.
Note: I have not developed custom manager.


I want your help with some sample code or link.

Thanks.

vivartpandey 12-02-2009 05:47 AM

For positioning button manager just override sublayout of main manager.
Code:

protected void sublayout(int width, int height) {           
buttonManager= getField(what-index-of-this-manager);
            buttonMgrHeight = buttonManager.getPreferredHeight();         
            layoutChild(footer, width, buttonMgrHeight );
          setPositionChild(footer, 0, Display.getHeight()- buttonMgrHeight );
            setExtent(width,height);
}

for fixed size button create a customButtonclass ,override layout method and fix the size.

clavemartin 12-02-2009 05:57 AM

What is 'buttonManager' and 'what-index-of-this-manager' and 'buttonMgrHeight ' here?

Thanks.

vivartpandey 12-02-2009 06:02 AM

Quote:

Originally Posted by clavemartin (Post 1519140)
I have developed a home screen of my application using VerticalFieldManager and added a background image, label, rich text field etc. I am trying add three buttons now. I want to have three buttons such as "Add", "Edit" and "Delete" buttons in entirely bottom of the screen with the same size. But if i add buttons using HorizontalFieldManager and add to main manager, it shows all the buttons in the top (next line of whatever the contols thee in the top) and also button size varies. How do i create same size buttons and move only those buttons to the bottom of the screen.
Note: I have not developed custom manager.


I want your help with some sample code or link.

Thanks.

that HFM i have taken as buttonmanager and in the main manager you can have more than one fields or managers so in getField(index)
you will pass the index of buttonmanager.

clavemartin 12-02-2009 06:17 AM

Resolved. Thank you very much. I am able to show the buttons in the bottom by using this.setStatus(horizontalFldManager);
May i know how can i make all the buttons with same size(height and width)

vivartpandey 12-02-2009 06:41 AM

In my application i am using only one MainScreen and for different screens, i am removing all fields and adding second screen's fields. so if i am using this.setStatus(HFM), this status will come in all screens.

clavemartin 12-02-2009 07:17 AM

I'm sorry, not getting exactly what is your explanation. Ok no worries, resolved anyway leave it. I also want to know how can i make the buttons size as same for all? I have three buttons and the code will be something like below..

class MySecondScreen extends MainScreen {

private HorizontalFieldManager horizontalFldManager;

public MySecondScreen ()
{
.................................................. ................
.................................................. .................

horizontalFldManager = new HorizontalFieldManager(Manager.USE_ALL_WIDTH);

ButtonField addButton;
addButton = new ButtonField("Add", ButtonField.CONSUME_CLICK);

ButtonField editButton;
editButton = new ButtonField("Edit", ButtonField.CONSUME_CLICK);

ButtonField deleteButton;
deleteButton = new ButtonField("Delete", ButtonField.CONSUME_CLICK);

horizontalFldManager.add(addButton);
horizontalFldManager.add(editButton);
horizontalFldManager.add(deleteButton);

this.setStatus(horizontalFldManager);

.................................................. ................

.................................................. ................


}

vivartpandey 12-02-2009 08:05 AM

customButton.java file
Code:

public class customButton extends ButtonField{

        int buttonWidth;
        public customButton(String label,long style,int width) {
                super(label,style);
                buttonWidth = width;
        }
        protected void layout(int width, int height) {
               
                super.layout(buttonWidth, height);
        }
}

main screen file
Code:

class MySecondScreen extends MainScreen {

private HorizontalFieldManager horizontalFldManager;

public MySecondScreen ()
{
.................................................. ................
.................................................. .................

horizontalFldManager = new HorizontalFieldManager(Manager.USE_ALL_WIDTH);

customButton addButton;
addButton = new customButton("Add", ButtonField.CONSUME_CLICK,50);

customButton editButton;
editButton = new customButton("Edit", ButtonField.CONSUME_CLICK,50);

customButton deleteButton;
deleteButton = new customButton("Delete", ButtonField.CONSUME_CLICK,50);

horizontalFldManager.add(addButton);
horizontalFldManager.add(editButton);
horizontalFldManager.add(deleteButton);

this.setStatus(horizontalFldManager);

.................................................. ................

.................................................. ................


}


clavemartin 12-02-2009 08:43 AM

Hello,

How it is possible to add two classes with different name in a single java file as you pasted like the code?

vivartpandey 12-02-2009 09:01 AM

yaar,
i am just giving you a hint for your problem.
like
in your class your will get compiler error on this line
.................................................. .................................................. .........
.................................................. .................................................. .........
did i say that both are in the same file.
first one is my class file and 2nd one is your class file with some modification.

you can write any no. of classes in your single file but public class should be one.

clavemartin 12-02-2009 09:07 AM

:) Well. Thanks. I knew it already, just was wondering. Anyway i created another file for Custom Button control. But now the buttons are created from custom class, doesn't show in the bottom of the screen, instead it is displaying top most place on the screen. Code is something like below ...

CustomControl buttonControl;
add(buttonControl = new CustomControl("Add", ButtonField.CONSUME_CLICK, 20) );
.................................................. ...........
.................................................. ...........
_container.add(mainVerticalManager);
this.add(_container);

clavemartin 12-02-2009 09:29 AM

I Resolved it completely vivartpandey. Thanks for your co-operation.

clavemartin 12-03-2009 05:43 AM

Multiple Data storage in my application.
 
Sorry for this...i created new thread for this ....


All times are GMT -5. The time now is 11:19 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.