BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-28-2009, 05:08 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2009
Model: Strom
PIN: N/A
Carrier: Vodafone
Posts: 28
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question How to do Text Wrapping for text in List Field with Checkboxes ?

Please Login to Remove!

Hi all,

I m creating a ListField with Checkboxes from How To - Create a ListField with check boxes

But I m not getting how to wrap Text in a row in that ListField.

I referred the thread Text Wrapping for text in List Field items

Here its written as

Code:
If all you are displaying is text, then I would go with the approach suggested by rab.
I m displaying Text only in ListField which I want to wrap if it doesnt fit within device screen.

But i m not getting "approach suggested by rab" in which How to calculate?

Code:
String [] linesToDraw = calculate the number of lines depending on the row width
I m stucked at this so any details on this issue ?
Offline  
Old 11-28-2009, 09:14 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

You can retrieve the width of you text ahead of time using Font.getAdvance(String text)

See the API Docs.

You would then calculate how may lines you need to display the text, and size the row accordingly.
Offline  
Old 12-01-2009, 02:06 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2009
Model: Strom
PIN: N/A
Carrier: Vodafone
Posts: 28
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question

I got the no. of lines properly according to row width & stored it in a Vector & i m doing

Code:
int fontHeight = this.getFont().getHeight();

         for (int i = 0; i < linesToDraw .size(); i++)
        {           
            textToDraw = (String)linesToDraw.elementAt(i);
            graphics.drawText(textToDraw, xpos, ypos, 0 , width);
            ypos += fontHeight;
        }
now its drawing the lines but over the previous one as by default listField.setRowHeight() is taking only one row. If there r 2 rows then I write setRowHeight(getFont().getHeight()*2) in drawListRow() but then it goes in loop.

If I write setRowHeight() while creating ListField then it comes properly but for all rows same row height is set.

I gets the String to draw at Runtime & the row height should be variable for different rows then how can I setRowHeight() with what parameter & in which method ?
Offline  
Old 12-02-2009, 04:59 AM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2009
Model: Strom
PIN: N/A
Carrier: Vodafone
Posts: 28
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question

Hi,

I got the Text in each row using row width (Font.getFont().getAdvance()) but how to calculate how may lines you need to display the text, and size of the row .
Offline  
Old 01-12-2010, 10:42 PM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2009
Model: Strom
PIN: N/A
Carrier: Vodafone
Posts: 28
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question

I m calculating the string to draw in drawListRow(....). After it I m setting the Row Height using setRowHeight(int). But when i write this method in drawListRow(....) then the output comes properly but it goes in loop. So where should i call setRowHeight(int) ?
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.