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
BlackBerry Development Advisor
Posts: 14,966
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Scroll on the vertical field manager in popup

Note that you will need a focusable field to allow for scrolling.  If you don't want a field to appear focusable you can accomplish this by adding some focusable NullFields to your screen/manager.  This should allow for scrolling but won't be visible to the user.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 74
Registered: ‎07-17-2008
My Device: Not Specified

Re: Scroll on the vertical field manager in popup

I Tried adding a Null Field at the bottom, but then it just got stuck in the bottom.

 

I ended up just changing the LabelField to a EditField with the readonly style

this works well for me.

 

Thanks. 

New Developer
Posts: 17
Registered: ‎02-06-2009
My Device: Not Specified

Re: Scroll on the vertical field manager in popup

Hi,

 I have same problem. Please help me to solved out this.

I am trying to implement scrolling functionality in Blackberry Strom application. I have to display one image which height is 500. But I have to display it in Vertical field manager with height 436 only. And I have to implement scroll feature to display that image within this layout. Strom has total display height is 480. But I have to place horizontal field below this main Vertical Field. Following is example code. Please guid me to solve this issue.

 

This is main class file MainLite.java

 

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.TouchEvent;
import net.rim.device.api.ui.TouchGesture;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.NullField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;








public class MainLite extends UiApplication //implements FieldChangeListener

{

public static void main(String[] args)

{

//create a new instance of the application

//and start the application on the event thread

MainLitetheApp = new MainLite();

theApp.enterEventDispatcher();

}


public MainLite()

{

//display a new screen

pushScreen(new MainScreenLite());


}


}

 

class MainScreenLite extends MainScreen implements FieldChangeListener




//VerticalFieldManager vfmHanuman0 = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR | VerticalFieldManager.VERTICAL_SCROLL |VerticalFieldManager.USE_ALL_WIDTH |VerticalFieldManager.FIELD_HCENTER | DEFAULT_CLOSE);


Manager mainMgr = new VerticalFieldManager();


HorizontalFieldManager hfmNavigation = new HorizontalFieldManager();

VerticalFieldManager vfmleft = new VerticalFieldManager(VerticalFieldManager.FIELD_HCENTER);

VerticalFieldManager vfmMiddle = new VerticalFieldManager(VerticalFieldManager.FIELD_HCENTER);

VerticalFieldManager vfmright = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH);



String Image;


drawimage mainscreenimage;

previousnext Previous;

previousnext Next;

middle Middle; 



public MainScreenLite() {


super();






try

{


Image="2.PNG";

mainscreenimage = new drawimage(Image,Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR | DEFAULT_MENU | DEFAULT_CLOSE |UPWARD );


mainMgr.add(mainscreenimage);

mainMgr.add(new NullField(Field.FOCUSABLE));

add(mainMgr);


}

catch (Exception e)

{


}


// Put Navigation Buttons and Events On Field Manager

Previous = new previousnext("About",Field.FOCUSABLE);

Previous.setChangeListener(this);

vfmleft.add(Previous);


Middle = new middle("Middle",Field.FOCUSABLE);

//Middle.setChangeListener(this); 

vfmMiddle.add(Middle);


Next = new previousnext("Next",Field.FOCUSABLE);

Next.setChangeListener(this); 

vfmright.add(Next);


hfmNavigation.add(vfmleft);

hfmNavigation.add(vfmMiddle);


hfmNavigation.add(vfmright);


add(hfmNavigation);


}

}

 

 

So I want to display Image name 2.PNG on Top (with vertical field manager, height is 436 for vertical field manager and image height is 500) and Next, Previous is in horizontal field manager. So I need 2.PNG scrollable.

 

Here is code to draw and setting layout for 2.PNG image and its draw class drawimage.java

 

import net.rim.device.api.system.Bitmap;


import net.rim.device.api.ui.Font;

import net.rim.device.api.ui.Graphics;

import net.rim.device.api.ui.container.VerticalFieldManager;




public class drawimage extends VerticalFieldManager

{


private String _label;

private int _labelHeight;

private int _labelWidth;


private Font _font;


private Bitmap _currentPicture;

private int fixedHeight;


/**

* Constructor.

* @param text - the text to be displayed on the button

* @param style - combination of field style bits to specify display

attributes 

*/

drawimage(String text, long style) 

{

super(style); 


_font = getFont();

_label = text;

_labelHeight = _font.getHeight(); 

_labelWidth = _font.getAdvance(_label); 

_currentPicture = Bitmap.getBitmapResource(text);

this.fixedHeight = 436;


}



/**

* @return The text on the button

*/


/**

* Field implementation.

* @see net.rim.device.api.ui.Field#getPreferredHeight()

*/

public int getPreferredHeight()

{

return fixedHeight;

}


/**

* Field implementation.

* @see net.rim.device.api.ui.Field#getPreferredWidth()

*/

public int getPreferredWidth() 

{

return _labelWidth + 8;

}



/**

* Field implementation.

* @see net.rim.device.api.ui.Field#layout(int, int)

*/

/* protected void layout(int width, int height) 



setExtent(360,436); 

}*/

protected void sublayout(int width, int height)

{

super.sublayout(width, fixedHeight); 

setExtent(width, fixedHeight);

//setExtent(width, 436);

}


/**

* Field implementation.

* @see net.rim.device.api.ui.Field#paint(Graphics)

*/

protected void paint(Graphics graphics) 


// Draw the background picture


graphics.drawBitmap(0,0,getWidth(),436, _currentPicture, 0, 0);



}

 

Here i have not given class file reference for Next & Previous field manager. They are add in Horizontal filed manager hfm with height 70. So it has no problem but I have maintian scrolling with vertical feild manager mainMgr.

Please help me.

 

Thanks in Advanced.
Vimal

BlackBerry Development Advisor
Posts: 14,966
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Scroll on the vertical field manager in popup

If you want to scroll up and down, you should add a focusable NullField to the top of your manager as well.  Can you provide a screen shot of what you see versus what you are trying to accomplish?  This will make your end goal more clean.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 17
Registered: ‎02-06-2009
My Device: Not Specified

Re: Scroll on the vertical field manager in popup

Thanks Mark,

 

Problem solved using  following code in drawimage.java

 

protected void sublayout(int width, int height)

    {

        super.sublayout(360, 500);  

        setVirtualExtent(360, 500);

        setExtent(360, 436);

    } 

 

Problem was that Screen size for Blackberry strom is Width:360, Height:480. I have to display Image with height 436pixel. But original height of Image was 500pixel. I don't want to allow full scrolling of Image in whole screen. So setting above code I got solution.

 

setVirtualExtent(360,500); will allow me scrolling up and down (Vertical) image even if Image display in screen area of (360 x 436).

 

Thanks again, I got reference it from your old post. 

Vimal 

New Developer
Posts: 1
Registered: ‎05-14-2009
My Device: Not Specified

Re: Scroll on the vertical field manager in popup

 Hello, well I don´t speak english very well and sorry if you don´t understoud :smileysad:

 

I have a problem with the scroll in VerticalFieldManager. In my program I have one VerticalFieldManager and a lot of HorizontalFieldManager included into VerticalFieldManager. Thouse HorizontalFieldManager includes a lot of VerticalFieldManager.

 

My BlackBerry Bold function fine but in BlackBerry Storm don´t function vertical scroll. Only function horizontal scroll.

 

Please anyone help me?

 

Thanks...

 

Att. Gonzalo Santomé

Developer
Posts: 178
Registered: ‎08-26-2009
My Device: Not Specified

Re: Scroll on the vertical field manager in popup

I know I'm rather late but anyone else who faces an issue, as Msolm suggested use two nullfields, one on the top and one at end of the Vertical Field Manager. Like this

 

add(new NullField(Field.FOCUSABLE)); <-- top of the VFM

<other labels and what not>

add(new NullField(Field.FOCUSABLE));