Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
sheetaloswal
Posts: 59
Registered: ‎03-06-2012
My Device: 9700
My Carrier: airtel

Issue is Horizontal scroll

Hi All,

 

  I have a screen like native calendar in Blackberry where i display data of the form "01a eve1 eeve2 eve3 eve4" when i screen width is reached ,its scrolls ,but i need the data "01a" to be stagnant i dont want it be moved while scroll .I am using the code like

 

    CustomHFM horizontalFieldManager_left15 = new CustomHFM(
                Manager.HORIZONTAL_SCROLL);

        HorizontalFieldManager hrzMgrTimeLabel = new HorizontalFieldManager(
                Manager.USE_ALL_HEIGHT) {

            protected void paint(Graphics g) {
                g.setBackgroundColor(0x646060);

                g.clear();
                super.paint(g);
            }
        };
        hrzMgrTimeLabel.add(time15);
        hrzMgrTimeLabel.add(min15);

        horizontalFieldManager_left15.add(hrzMgrTimeLabel);

        horizontalFieldManager_left15.add(labelField15[x]);

 

public class CustomHFM extends HorizontalFieldManager {

    private long style;

    public CustomHFM(long style) {
        super(HORIZONTAL_SCROLL);
        style = style;
    }

    public int getPreferredWidth() {
        return Display.getWidth();
    }

    // define height
    public int getPreferredHeight() {
        return 40;
    }

    protected void sublayout(int maxWidth, int maxHeight) {
        super.sublayout(getPreferredWidth(), getPreferredHeight());
        setExtent(getPreferredWidth(), getPreferredHeight());
    }

 

How to handle this ? Please expalin with a snippet ,i know that i am applying HorizontalScroll to entire components but how to avoid only "01a" here

    hrzMgrTimeLabel.add(time15);
        hrzMgrTimeLabel.add(min15); implies '01' and 'a' labelfield.

 

 

Please use plain text.
Developer
jitendrasharma
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: Issue is Horizontal scroll

in ScreenConstructer, set NO_HORIZONAL_SCROLL. Flag by calling

 

super(NO_HORIZONTAL_SCROLL);

 

Now in this Screen Add A HorizontalFieldManager with Properties:

 

HorizontalFieldManager hfmFullRow= new HorizontalFieldManager()
{
    public int getPreferredWidth()
    {
       return Display.getWidth();
    }

    public int getPreferredHeight()
    {
        return 60;
    }
    
    public void sublayout()
    {
        super.sublayout(getPreferredWidth(), getPreferredHeight());
        super.setExtent(getPreferredWidth(), getPreferredHeight());
        
    }
}

 

In this Hfm add two managers with following properties:

 

HorizontalFieldManager hfmStatic= new HorizontalFieldManager()
{
    public int getPreferredWidth()
    {
       40;
    }

    public int getPreferredHeight()
    {
        return 60;
    }
    
    public void sublayout()
    {
        super.sublayout(getPreferredWidth(), getPreferredHeight());
        super.setExtent(getPreferredWidth(), getPreferredHeight());
        
    }
}

 

and Second For Scrollable Manager

 

HorizontalFieldManager hfmscrollable= new HorizontalFieldManager(HorizontalFieldManager.HorizontalScroll)
{
    public int getPreferredWidth()
    {
       return Display.getWidth()-40;
    }

    public int getPreferredHeight()
    {
        return 60;
    }
    
    public void sublayout()
    {
        super.sublayout(getPreferredWidth(), getPreferredHeight());
        super.setExtent(getPreferredWidth(), getPreferredHeight());
        
    }
}

 

Please use plain text.