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
Developer
bo
Posts: 167
Registered: ‎11-12-2008
My Device: Not Specified

ListField with varying row heights

How does one go about doing this?  I read this thread here: http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=5011&query.id=306...

 

and I discovered that there is an undocumented method called  setRowHeight(index, height).

 

However, I would prefer not to use an undocumented method and when I do use setRowHeight(index, height) the UI is choppy when scrolling.  It seems I am unable to loop through the rows of the list beforehand and call setRowHeight.  For some reason it seems like it has to be called after painting.

 

Any help would be appreciated. 

 

Thanks.

 

 

Developer
Zeeshan0581
Posts: 86
Registered: ‎01-09-2009
My Device: Not Specified

Re: ListField with varying row heights

after you declare the ListField object and initiate it.  use the list.setRowHeights(int) method.

To have varying Field Heights, I tried it but just like you said UI was not smooth, So i ended up

using multiple listfields with different callbacks and different heights.  Just a thought

Developer
Developer
bo
Posts: 167
Registered: ‎11-12-2008
My Device: Not Specified

Re: ListField with varying row heights

Thanks for the response!

 

I suppose I could create a wrapper around my current class that loops through my row managers and if the current row manager's preferred height is different than the last, it will create a new ListField with that row's preferred height.  Seems like a little a bit of a pain, but I'll try that unless anyone else has any other ideas.

Developer
gregzav
Posts: 170
Registered: ‎01-17-2009
My Device: 9630

Re: ListField with varying row heights

[ Edited ]
I did this by overriding the paint method
Message Edited by gregzav on 02-17-2009 05:58 PM
Developer
Developer
bo
Posts: 167
Registered: ‎11-12-2008
My Device: Not Specified

Re: ListField with varying row heights

In what way did you override the paint method?  I wanted to actually have each row really be a manager, and have it call subpaint, so its fields actually lay themselves out and the label fields wrap.  I wasn't sure how to make drawText wrap text.  What I was going for was this:

 

[wrapped text wrapped text wrapped text] [image]

[wrapped text wrapped text wrapped text]


the wrapped text could end up being anywhere between 1 and 4 lines.
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: ListField with varying row heights

If you are going to have multiple list fields just so the rows are a different height, you might as well not even use a list field.

 

You can use a RichTextField to wrap text.

Developer
Developer
bo
Posts: 167
Registered: ‎11-12-2008
My Device: Not Specified

Re: ListField with varying row heights

[ Edited ]

The problem is that I want the highlighting and scrolling that comes along with a ListField.  Previously I had implemented rows of managers that changed background when a field within them gained focus.  However, scrolling was weird and I had to do complicated stuff like set the focus on a NullField on the bottom of the manager temporarily so the entire manager would be on the screen, not just the field in focus.  You'll notice that the entire row of a ListField is visible during scrolling.  This solution worked for a small number of rows, but with 200, everything grinds to a halt.

 

If you're familiar with the Facebook application, this is what I'm going for:

 

 

My one extra requirement is to make the rows variable in height and have text that wraps.  You'll notice that facebook cops out and uses an ellipsis, so they're probably using drawText.

Message Edited by bo on 02-18-2009 11:52 AM
New Developer
facultiesindia
Posts: 1
Registered: ‎03-04-2009
My Device: Not Specified

Re: ListField with varying row heights

I'm also having a similar requirement. I wanted to show list of latest headlines. Since some headlines can go beyond one display line, i wanted to know any easy way to wrap the text using listfield.

 

Any help on this would be greatly appreciated.

 

Thanks

 

Developer
gregzav
Posts: 170
Registered: ‎01-17-2009
My Device: 9630

Re: ListField with varying row heights


facultiesindia wrote:

I'm also having a similar requirement. I wanted to show list of latest headlines. Since some headlines can go beyond one display line, i wanted to know any easy way to wrap the text using listfield.

 

Any help on this would be greatly appreciated.

 

Thanks

 


I think your best option would be to use LabelFields instead of ListFields unless you want to implement your own text wrap...

 

Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800

Re: ListField with varying row heights

Hi,

     You can use as follows:

 

for(int i = 0; i < elements.size(); i++) // elements is the variable representing items in list field
    listField.setRowHeight(i, (i + 1) * 50);

 

This would help you to solve the problem.

 

Please press like, if you satisfied with the answer.