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: 122
Registered: ‎07-28-2009
My Device: Not Specified
Accepted Solution

how to Scroll only a part of screen......

Hi,

                I am developing a BlackBerry Application in JDE. I have developed a screen in which the Top most part is the heading, and below that i have lot of contents which have to be scrolled. The problem i am facing is when i scroll my content even the heading gets scrolled where as i need it to be static or should not be scrolled only the contents should be scrolled.

                  I have extended Screen and called

                super( new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL|VerticalFieldManager.VERTICAL_SCROLLBAR) );  

            

 

Hall of Famer III
Posts: 58,456
Registered: ‎11-28-2008
My Device: DTEK50 (AAI82), PRIV (AAI795), Z10/Z30/Q10 (10.3.2.2813), Playbook (2.1.0.1917)
My Carrier: TMobile USA

Re: how to Scroll only a part of screen......

Hi there!


FYI -- you've posted this to the Device Support forum...not usually for assistance with development questions. But, don't double-post, we will have this moved momentarily to the correct place:

http://supportforums.blackberry.com/rim/board?board.id=java_dev

That way, the right experts will have the best visibility.

Good luck!


Occam's Razor nearly always applies when troubleshooting technology issues!

New to the Community? Click here and also here for helpful guidance. Also please click here for additional helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions. If anyone has been helpful to you, please show your appreciation by clicking the button. Need a reference to BB10 OS/SR versions? Click here. Need a specific BB10 AutoLoader? Send me a private message.

...................................................... ......................................................
Developer
Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: how to Scroll only a part of screen......

Sounds like you want to do this?
Developer
Posts: 106
Registered: ‎06-18-2009
My Device: Bold

Re: how to Scroll only a part of screen......

You could use MainScreen.  It provides a title bar for you by default.  You can either set it with a string or add your own Fields to it. Then you can add all the rest of your fields to the body of the screen just like you added it to the Screen. 

 

If you do want your own custom Screen implementation,you need to create a custom Manager that has a heading/title area and a main content area and make it non-scrollable.  Then add another manager with vertical scroll in the main content area and add all your fields to this manager. 

----
If this helped you, press the thumbs up button (on the far right - '+' thumb icon)
If this post solved the issue, click "Accept as Solution"
Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: how to Scroll only a part of screen......

New Developer
Posts: 122
Registered: ‎07-28-2009
My Device: Not Specified

Re: how to Scroll only a part of screen......

Hi filiussoft,

                         Thank u4  reply. You told me use MainScreen so that i can use setTitle and set the title, but in my applicatiuon i am extending Screen and i am placing a background image and it is possible by first calling the following in constructor :-

      

 super( new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL | VerticalFieldManager.VERTICAL_SCROLLBAR) );

         

 Then i have define subleyout method as following :-

 

    protected void sublayout( int width, int height )
    {
        setExtent(C_CUSTOM_Width,C_CUSTOM_Height );
        setPosition( C_X,C_Y );
        layoutDelegate(C_CUSTOM_Width,C_CUSTOM_Height );
    }

 

Then i have painted the back Groung using the followin code :-

 

Bitmap img_Background = Bitmap.getBitmapResource("com.zylog/res/images/BlueBackGround.png");

which calls the following metyhos to paintBackground with our desired image.

    protected void paintBackground(Graphics g)
    {
         g.drawBitmap(0,0,img_Background.getWidth(),img_Background.getHeight(),img_Background,0,0); //Background img         
     
    }

 

 


 

So i extend Screen class and this is my code to paint a background with my desire image...kindle tell me how to scroll only my contents with out scrolling the heading when i use Screen. If ur telling Custom Screen then kindle guide me on Custom Screen with a Title and heading and my contents only scrolling and Title and hading remaing constant with out scrolling......

 

 

New Developer
Posts: 122
Registered: ‎07-28-2009
My Device: Not Specified

Re: how to Scroll only a part of screen......

Hi

Developer
Developer
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Re: how to Scroll only a part of screen......

Perlwhite,

 

I have modified the code that was mentioned in one of the previous links.

So you can use it as is, just add to it whatever details you have.

The code has a headerManager that does not scroll, and a contentManager that scrolls.

You do not need to customize any screen. Just use the two managers and add them to MainScreen or FullScreen, or even to your customized screen( that is not needed).

The background drawing is done by the two  managers themselves. So the background of the parent screen is never visible, it should not be a concern.

 

import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.system.*; class TestScreen extends MainScreen{ private VerticalFieldManager contentManager; private HorizontalFieldManager headerManager; TestScreen() { super(NO_VERTICAL_SCROLL); LabelField demoText = new LabelField("Hello World Demo", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); headerManager = new HorizontalFieldManager() { protected void paintBackground(Graphics graphics) { graphics.setBackgroundColor(0x00382B79); graphics.clear(); super.paint(graphics); } }; headerManager.add(demoText); this.add(headerManager); Bitmap img_Background = Bitmap.getBitmapResource("com.zylog/res/images/BlueBackGround.png"); //rather than adding component in the mainScreen //add components in this verticalManager and then // add this manager to mainScreen contentManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR) { /* public void paint(Graphics graphics) { graphics.setBackgroundColor(0x00ffffff); graphics.clear(); super.paint(graphics); } */ protected void paintBackground(Graphics g) { g.drawBitmap(0,0,img_Background.getWidth(),img_Background.getHeight(),img_Background,0,0); //Background img } protected void sublayout( int maxWidth, int maxHeight ) { int width = Display.getWidth(); int height = Display.getHeight() - headerManager.getHeight(); super.sublayout( width, height); setExtent( width, height); } }; // create a couple of buttons for testing only ButtonField button1 = new ButtonField("Button1"); ButtonField button2 = new ButtonField("Button2"); contentManager.add(button1); contentManager.add(button2); this.add(contentManager); } }

 

 

Rab

New Developer
Posts: 122
Registered: ‎07-28-2009
My Device: Not Specified

Re: how to Scroll only a part of screen......

Hi rab,                   Thank u for ur code, its good, well can u pls implement the same thing when we extend the Screen instead of MainScreen class. Actually me requirement is strictly in Screen.

Developer
Developer
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Re: how to Scroll only a part of screen......

perlwhite,

 

Here you go. I modifief the code to extend the class Screen instead of MainScreen.

I tested it on the bold simulator and it worked fine. I can send you a snap shot if you want.

(Of course I used my own Bitmap for the background )

 

Rab

 

import net.rim.device.api.io.MIMETypeAssociations; import net.rim.device.api.system.Characters; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.system.*; import net.rim.device.api.i18n.*; import java.io.*; import java.util.Vector; import net.rim.device.api.ui.UiApplication; import javax.microedition.io.*; import javax.microedition.io.file.*; public class TestScreen extends Screen{ private VerticalFieldManager contentManager; private HorizontalFieldManager headerManager; Bitmap img_Background = null; public TestScreen() { super(new VerticalFieldManager(),NO_VERTICAL_SCROLL); LabelField demoText = new LabelField("Hello World Demo", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); headerManager = new HorizontalFieldManager() { protected void paintBackground(Graphics graphics) { graphics.setBackgroundColor(Color.YELLOW); graphics.clear(); super.paint(graphics); } }; headerManager.add(demoText); this.add(headerManager); img_Background = Bitmap.getBitmapResource("com.zylog/res/images/BlueBackGround.png"); //rather than adding component in the mainScreen //add components in this verticalManager and then // add this manager to mainScreen contentManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR) { protected void paintBackground(Graphics g) { g.drawBitmap(0,0,img_Background.getWidth(),img_Background.getHeight(),img_Background,0,0); //Background img } protected void sublayout( int maxWidth, int maxHeight ) { int width = Display.getWidth(); int height = Display.getHeight() - headerManager.getHeight(); super.sublayout( width, height); setExtent( width, height); } }; // create a couple of buttons for testing only contentManager.add(new ButtonField("Button1")); contentManager.add(new ButtonField("Button2")); contentManager.add(new ButtonField("Button3")); contentManager.add(new ButtonField("Button4")); contentManager.add(new ButtonField("Button5")); contentManager.add(new ButtonField("Button6")); contentManager.add(new ButtonField("Button7")); contentManager.add(new ButtonField("Button8")); this.add(contentManager); } protected void sublayout( int width, int height ) { setExtent(width,height ); setPosition( 0,0 ); layoutDelegate(width,height ); } }