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
New Developer
brchase
Posts: 5
Registered: ‎07-20-2008
My Device: Not Specified
Accepted Solution

HorizontalFieldManager with ListCallback?

I'm using JDE 4.2.1 and am adding horizontal fields to ListCallback rowsCurrently I have overriden the drawListRow method of ListCallback to allow an icon and 4 columns of data to be added to each row:

 

g.drawBitmap(4,y+4,14,14,myBitMap,0,0);   
g.drawText(_column1,20,y,0,w/2-w/4+2);
g.drawText(_column2,w/2-w/4+6,y,0,w/2-w/8-2);
g.drawText(_column3,w/2-w/8+2,y,0,w-w/8-9);
g.drawText(_column4,w-w/8-5,y,0,w); 

 

This has required me to perform substring operations on each of the column strings to ensure they won't overlap with the next columnI think I need to use HorizontalFieldManager to add the columns in a more logical and predictable fashion (output looks ok on 8830, but not on Pearl for example).  I'm also hoping that HFM will provide automatic substring operations and add "...." at the right of the field if a substring is shownIs that the caseIf it is can someone point me to an example of using HorizontalFieldManager with ListCallback?

 

 

Please use plain text.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: HorizontalFieldManager with ListCallback?

As far as I know HorizontalFieldManager does not provide such functionality.

 

It does not shrink visible area nor shows ellipsis instead of long strings.

 

You have to check it by yourself.

 

Use getAdvance() method of Font class to calculate width of a string.

 

And use Display.getScreenWidth() method to calculate the screen width.

 

And in cases when your string is too big to be displayed - make it short.

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: HorizontalFieldManager with ListCallback?

Agree with everything that tbilisoft has said, just wanted to add a couple of points:

 

a) I typically break the display width up into columns, in pixels, and then use the Graphic methods to display the data in these columns.  See the following post for an example:

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=9247&query.id=256...

 

b) ListField uses a getPreferredWidth callback to determine its width.  I have used this to reduce the width of a ListField.  I have never tried to to increase the width.  Might be worth a try?

 

Please use plain text.