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
New Developer
Posts: 20
Registered: ‎01-05-2009
My Device: Not Specified
Accepted Solution

MainScreen Scolling Issue with Custom Fields

I have developed a class which extends Field and Implements DrawStyle. The field contains a bitmap with text drawn to the left of it...nothing too complicated. I made it focasable, have overwritten layout and drawFocus, paint, etc, but I'm having a visual anomaly.

 

On my MainScreen (no title) I have added a LabelField (non-focusable), then a BitmapField (non-focusable), followed by a number of my custom fields. When the screen first loads, everything looks great; my first custom control has focus and is drawn as such.

 

The problem occurs when I scroll past the 3rd custom control to the 4th (causing the MainScreen to scroll), the 2nd custom control appears twice, the 3rd is missing and the 4th has focus. There is also some white background which starts to show through (my controls are all black and so is the background of the MainScreen and other controls).

 

Obviously I'm having some painting issues, but it definitely related to the scrolling.

 

What methods need to be overritten in a custom control to ensure scrolling will work correctly?

 

What needs to be set in the MainScreen?

Highlighted
Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: MainScreen Scolling Issue with Custom Fields

1. Make your MainScreen unscrollable like:

    super(NO_VERTICAL_SCROLL);

 

2. Use a VerticalFieldManager for adding all your components.

    Make that verticalManager Scrollable and set its size and background color.

    Something like:   

mainManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR) { //setting background color protected void paintBackground(Graphics graphics) { graphics.setBackgroundColor(0x00000000); graphics.clear(); super.paint(graphics); } //setting its height and width protected void sublayout( int maxWidth, int maxHeight ) { int width = Display.getWidth(); int height = Display.getHeight(); super.sublayout( width, height); setExtent( width, height); } };

3. Now add this  to your screen.

Now your screen will not scroll and you will not get the white background at the end.

 

Let me know if you have any question.

 

 

Regards

Bikas


 

    

    

Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: MainScreen Scolling Issue with Custom Fields

Hi,

 

have look at this thread you will have to use invalidate().

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=30282

 

Let me know if your problem get solved or not.

 

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
New Developer
Posts: 20
Registered: ‎01-05-2009
My Device: Not Specified

Re: MainScreen Scolling Issue with Custom Fields

Thanks Bikas,

 

That worked like a charm. For other novice BB developer out there to add the VerticalFieldManager to the MainScreen call the MainScreen's add() method, which accepts a Field as a parameter, but can accept a Manager as well Smiley Wink

 

 

Greg

Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: MainScreen Scolling Issue with Custom Fields

You are welcome. Smiley Happy