09-19-2012 09:30 AM
Hi Everyone,
I have a legacy code which uses VerticalFieldManager inside an AbsoluteFieldManager. And i need to scroll down in the VerticalFieldManager. If i by pass the AbsoluteFieldManager and add the VerticalFieldManager to the screen directly scrolling works fine but in AbsoluteFieldManager it does not.
Could you please advice on how to solve this problem ?
Sample code is below,
Regards,
package mypackage;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.container.MainScreen;
/**
* A class extending the MainScreen class, which provides default standard
* behavior for BlackBerry GUI applications.
*/
public final class MyScreen extends MainScreen
{
/**
* Creates a new MyScreen object
*/
public MyScreen()
{
super(Manager.NO_VERTICAL_SCROLL);
// Set the displayed title of the screen
setTitle("MyTitle");
}
}
package mypackage; import net.rim.device.api.ui.Manager; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.LabelField; import net.rim.device.api.ui.component.NullField; import net.rim.device.api.ui.component.SeparatorField; import net.rim.device.api.ui.container.AbsoluteFieldManager; import net.rim.device.api.ui.container.VerticalFieldManag er; /** * This class extends the UiApplication class, providing a * graphical user interface. */ public class MyApp extends UiApplication { /** * Entry point for application * @param args Command line arguments (not used) */ public static void main(String[] args) { MyApp theApp = new MyApp(); theApp.enterEventDispatcher(); } /** * Creates a new MyApp object */ public MyApp() { MyScreen myScreen = new MyScreen(); //Create a scrollable VerticalFieldManager. VerticalFieldManager vfm = new VerticalFieldManager(VerticalFieldManager.VERTICAL _SCROLL); //Add a focusable NullField to the top of the screen to allow the user to scroll to the top. vfm.add(new NullField(NullField.FOCUSABLE)); //Add 10 fields. for (int count = 30; count >= 0; --count) { vfm.add(new LabelField("Field number " + count, LabelField.NON_FOCUSABLE)); vfm.add(new SeparatorField()); } //Add a focusable NullField to the bottom of the screen to allow the user to scroll to the bottom. vfm.add(new NullField(NullField.FOCUSABLE)); AbsoluteFieldManager manager = new AbsoluteFieldManager(); manager.add(vfm); myScreen.add(manager); pushScreen(myScreen); } }
09-19-2012 09:35 AM
09-21-2012 01:50 AM
Hi,
thanks for the reply but above code is just a sample code to show to problem i face.
Normally i am adding the vertical manager to the absolute manager with x, y coordinates. And i also do some stuff on the absolute manager like showing a header and bg image...
09-21-2012 12:01 PM
Unfortunately, AbsoluteFieldManager seems to have been added to BlackBerry as an afterthought, and it has some serious problems with layout. I'm not sure it properly sets its virtual extent.
I suggest looking at this old post to get some understanding of how layout should be done - you might want to import some of that into your code, overriding AFM's sublayout, calling super.sublayout there and then going through the fields and finding out your actual dimensions:
AbsoluteFieldManager on OS prior to 5.0
There was at least one poster here who made use of that:
Horizontal Scrolling in AbsoluteFieldManager
Besides, there were reports about some genuine bugs with AFM:
Good luck weeding out this problem!