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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
delidumrul
Posts: 9
Registered: ‎05-23-2012
My Carrier: turkcell

VerticalFieldManager scroll problem when inside an AbsoluteFieldManager

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.VerticalFieldManager;

/**
 * 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);
    }    
}

 

Please use plain text.
Developer
simon_hain
Posts: 13,754
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: VerticalFieldManager scroll problem when inside an AbsoluteFieldManager

why do you use an absolutefieldmanager if you don't use its functionality?
to use it properly you should most likely use http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/container/AbsoluteFieldMana...

addig fields in loops is very costly, better use addAll.
or use a listfield instead of 30 labels.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Contributor
delidumrul
Posts: 9
Registered: ‎05-23-2012
My Carrier: turkcell

Re: VerticalFieldManager scroll problem when inside an AbsoluteFieldManager

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...

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Carrier: various

Re: VerticalFieldManager scroll problem when inside an AbsoluteFieldManager

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:

Bug with AbsoluteFieldManager

 

Good luck weeding out this problem!

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.