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
Contributor
Hitman47
Posts: 33
Registered: ‎05-14-2010
My Device: Blackberrry Pearl 8320
Accepted Solution

Creating a grid?

Ok so does anyone know an easy/good way to create a grid using the BB RIM API?

 

I want it to be so that I can customize it (example One row have 3 columns, and one have just 1 the size of all the 3)

 

The only way Im thinking how to do it is just add fields in a manager, and then lay them out like I want them to. However I was wonderinf if theres an already existing class that does that (or something like that)

 

One of the problems I encounter with a manager, is that from a field you can go only to the next field(not from 1 field, to the one on its right or down)

Developer
sonicboomboy
Posts: 466
Registered: ‎03-04-2009
My Device: 8520

Re: Creating a grid?

well, there is a GridManager in JDE 5.0 http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/container/GridFieldManager....

also there is an ready-to-use example from rim known as TableLayoutManager 

http://supportforums.blackberry.com/t5/Java-Development/Create-a-rich-UI-layout-with-TableLayoutMana...

 

you migth find useful that.

Got resolved! Press kudo icon!
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Creating a grid?

AFAIK, TableLayoutManager will not create variable column sizes on each row as you require.  Don't know about GridManager.

 

The problem you are facing - focus movement moving in and out of Managers - is unfortunately a common problem.  I am not aware of an easy way around this.  I believe that most people end up overriding focus movement methods in the associated Managers. 

Contributor
Hitman47
Posts: 33
Registered: ‎05-14-2010
My Device: Blackberrry Pearl 8320

Re: Creating a grid?

[ Edited ]

Ok this almost solved my problem.
The other thing is how to make it so that

- right goes to the next column

- down goes to the next row


EDIT: I didnt see your reply Peter.

 

Ye when I first looked at TLM I thought I could resize the column for each row, but it seems I was wrong.

 

And is the overwriting of the trackball direction field choosing (idk what the function is called), normally doable? Im thinking of doing a small app just to try it out, but maybe I can find the answer here faster

Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Creating a grid?

 


Hitman47 wrote:

Ok this almost solved my problem.
The other thing is how to make it so that

- right goes to the next column

- down goes to the next row


 

That's exactly what Peter has said in the post above yours.  You'll have to override your navigationMovement() methods to customize the behavior (I don't think moveFocus() is smart enough to distinguish between horizontal and vertical movement).  Something along the lines of

 

protected boolean navigationMovement(int dx, int dy, int status, int time) {

    if (dx != 0) {

        return customHorizontalMovement(dx);

    } else if (dy != 0) {

        return customVerticalMovement(dy);

    }

    return super.navigationMovement(dx, dy, status, time);

}

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
sonicboomboy
Posts: 466
Registered: ‎03-04-2009
My Device: 8520

Re: Creating a grid?

Override the navigationMovement (...) method in your manager to handle various movements.

Got resolved! Press kudo icon!
Contributor
Hitman47
Posts: 33
Registered: ‎05-14-2010
My Device: Blackberrry Pearl 8320

Re: Creating a grid?

[ Edited ]

I didnt see Peter's reply. I edited my post.


Also Peter, do you have any good suggestions to do different size/number of columns in different rows within a manager?

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Creating a grid?

"do you have any good suggestions..."

 

I wish I did.

 

In fact arkadyz is much better at this sort of UI stuff than I am.  So I think I shall reidrect this question to him!

Contributor
Hitman47
Posts: 33
Registered: ‎05-14-2010
My Device: Blackberrry Pearl 8320

Re: Creating a grid?

Lol I like how you guys all know each other, and who's best at what.

 

So I guess question re-directied to arkadryz.

 

The 2 solutions i was thinking of are:

1- Create a list of HorizontalFieldManagers, in which each one has different coloumns

2- Create a ListField out of HorizontalFieldManagers.

 

Again Im not sure if the focus change would work, especially on the ListField

Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Creating a grid?

Well, I'm not "best at" much, but I did implement a very complex custom manager a couple of months ago so now all this Manager/layout/paint stuff is quite natural to me.  However, I haven't used any fancy features as we still have a lot of customers with 4.2.1 OS on their phones, so even net.rim.device.api.ui.decor was denied to me.  Gave me a chance to learn a lot about custom painting!

 

I've taken a look at GridFieldManager and indeed the rows and columns have straight line boundaries.  So your idea of a list of HorizontalFieldManagers (have an enveloping VerticalFieldManager or just a MainScreen and add those HFM's to it) is a sound one.

 

In order for vertical movement to work intuitively, you'll have to hold the current horizontal position (your active Field's left boundary or center - whichever you prefer), update it on horizontal movements and use it to determine which field is to get focus on vertical movements.  For this, take a look at Field.getExtent() and HorizontalFieldManager.getFieldAtLocation(int x, int y) for starters.

 

If you are ready to scroll the screen both vertically and horizontally, decide what will scroll sideways - your whole screen (if yes, create your MainScreen with HORIZONTAL_SCROLL style in addition to VERTICAL_SCROLL) or just the Manager with the active field (then use HORIZONTAL_SCROLL in each of those HFMs).  If you decide to scroll them separately, take a look at Manager.NO_SCROLL_RESET flag - think whether you want to use it.

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