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
Developer
Posts: 44
Registered: ‎08-19-2009
My Device: Not Specified
Accepted Solution

Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

Hi all,

 

does anybody know a solution for this:

 

When I set HORIZONTAL_SCROLL as style for a GridFieldManager I can't scroll horizontal. The same code with a HorizontalFieldManager works fine. I work with the eclipse BlackBerry plug-in 5.0.0 . I already searched the forum but found no solution. I have the feeling its only a simple error. Please help.

 

Thanks for any help in advance.

 

 

Regards

 

Andreas

 

 

Here is a code snippet:

 

public class MyGFMHScroll extends UiApplication{
    public static void main(String[] args)    {
     MyGFMHScroll theApp = new MyGFMHScroll();      
        theApp.enterEventDispatcher();
    }
    public MyGFMHScroll()    {       
        pushScreen(new MyGFMHScrollScreen());
    }   
}
final class MyGFMHScrollScreen extends MainScreen{
 MyGFMHScrollScreen()    {       
        setTitle("GridFieldManager Horizontal Scroll Test");
  HorizontalFieldManager gfm = new HorizontalFieldManager( Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR);
//  GridFieldManager gfm = new GridFieldManager(1,6, Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR);
  gfm.add(new ButtonField("Button 1"));
  gfm.add(new ButtonField("Button 2"));
  gfm.add(new ButtonField("Button 3"));
  gfm.add(new ButtonField("Button 4"));
  gfm.add(new ButtonField("Button 5"));
  gfm.add(new ButtonField("Button 6"));
  add(gfm);
    }
}

Developer
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

call in your constructor super(No_HORIZONTAL_SCROLL);

Developer
Posts: 44
Registered: ‎08-19-2009
My Device: Not Specified

Re: Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

Hi ankit2groover,

 

thanks for your quick reply. Did you mean it like that:

 

final class MyGFMHScrollScreen extends MainScreen{
 MyGFMHScrollScreen()    {
  super(NO_HORIZONTAL_SCROLL);
        setTitle("GridFieldManager Horizontal Scroll Test");

The Horizontal scroll does not work in the simulator with the change. Smiley Surprised(

 

Andreas

Highlighted
Developer
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

am not sure why it is not working, but just testing it with some other ways around..................

 

ok, remove super(NO_HORIZONTAL_SCROLL) & in your grid manager add NullField before adding any other field & in last add another NULLFIELD after adding all the fields, generally for scrolling we need to add NULLFIELD in start & end for Horizontal & Vertical .......................

Developer
Posts: 44
Registered: ‎08-19-2009
My Device: Not Specified

Re: Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

I made it as you wrote:

 

  GridFieldManager gfm = new GridFieldManager(1,6, Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR);
  gfm.add(new NullField());
  gfm.add(new ButtonField("Button 1"));
  gfm.add(new ButtonField("Button 2"));
  gfm.add(new ButtonField("Button 3"));
  gfm.add(new ButtonField("Button 4"));
  gfm.add(new ButtonField("Button 5"));
  gfm.add(new ButtonField("Button 6"));
  gfm.add(new NullField());
  add(gfm);

and get an IllegalStateException and the simulator says:

 

"Uncaught Exception:

GridFieldManager.add called with no unoccupied fields."

 

Andreas

Developer
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

Just a question out of curiosity why you are initializing GridFieldManager with new GridFieldManager(1,6,Manager.HORIZONTAL_SCROLL) ?.................

 

According to the document in below link  it is mentioned that if your fields extend the row width then automatically it will  scroll horizontally if the widths of the columns exceed the visible width of the grid.

 

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/container/GridFieldManager....

 

So , according to my view i think you should initialize GridFieldManager with something like that

 

new GridFiledManager(1,6,GridFieldManager.AUTO_SIZE)................................

 

Am not sure about whether it will work or not , but to me this seems right....................

 

However , I use GridFieldManager but that is a customized one which will work for OS less than 5.0 , so that i could target all the devices & it works perfectly....................................

 

This is the link for implementing GridFieldManager for OS < 5.0

 

http://www.thinkingblackberry.com/archives/116

 

http://www.thinkingblackberry.com/archives/133

Developer
Posts: 44
Registered: ‎08-19-2009
My Device: Not Specified

Re: Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

thank you for your patience, ankitgrover. You meant that:

 

final class MyGFMHScrollScreen extends MainScreen{
 MyGFMHScrollScreen()    {
        setTitle("GridFieldManager Horizontal Scroll Test");
//  HorizontalFieldManager gfm = new HorizontalFieldManager( Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR);
  GridFieldManager gfm = new GridFieldManager(1,8,GridFieldManager.AUTO_SIZE);
  gfm.add(new ButtonField("Button 1"));
  gfm.add(new ButtonField("Button 2"));...

It doesn't work. I've read the api too. It should scroll automatically if the horizontal size doesn't fit in the screen. I think this is a bug.

 

Yeah, I've read the article on thinkingblackberry.com too. That is what a profi would do. But I thought as a beginner I should give RIMs GridFieldManager a try.

 

Andreas

New Contributor
Posts: 7
Registered: ‎05-25-2010
My Device: 9550
My Carrier: Developer

Re: Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

Hello Friend,

Try this .....It will work for scrolling.....

 

public class MyGFMHScroll extends UiApplication{
    public static void main(String[] args)    {
     MyGFMHScroll theApp = new MyGFMHScroll();      
        theApp.enterEventDispatcher();
    }
    public MyGFMHScroll()    {       
        pushScreen(new MyGFMHScrollScreen());
    }   
}
final class MyGFMHScrollScreen extends MainScreen{
 MyGFMHScrollScreen()    {
     super(HORIZONTAL_SCROLL);
        setTitle("GridFieldManager Horizontal Scroll Test");
  //HorizontalFieldManager gfm = new HorizontalFieldManager( Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR);

  GridFieldManager gfm = new GridFieldManager(1,6, Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR);
  gfm.add(new ButtonField("Button 1"));
  gfm.add(new ButtonField("Button 2"));
  gfm.add(new ButtonField("Button 3"));
  gfm.add(new ButtonField("Button 4"));
  gfm.add(new ButtonField("Button 5"));
  gfm.add(new ButtonField("Button 6"));
  add(gfm);
    }
}

Praveen Agrawal
Jr. Software Engineer

Developer
Posts: 44
Registered: ‎08-19-2009
My Device: Not Specified

Re: Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

Hi praveenagrawal,

 

yes that was the solution. Thank you very much.

 

Andreas

New Contributor
Posts: 3
Registered: ‎07-21-2010
My Device: Not Specified

Re: Newbie: GridFieldManager ignores HORIZONTAL_SCROLL

This really saved a lot of time.... my kudos to u Smiley Happy