How to do Text Wrapping for text in List Field with Checkboxes ?
- 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.
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
11-28-09 05:11 AMLike 0 - 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.
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
For example say the width of your screen is the line below.
________________________________
This row is a long string of characters that goes off the screen.
drawListRow needs to figure out where to split the lines. So it would get the width of the entire string, see that it's too long, and start removing words until it gets a string that is less wide than the screen. It'd eventually be left with "This row is a long string of" "characters that goes off the screen."
To me, it seems like too much of a pain to do this. Instead, what I did was create a marquee scroller. If the text is too long, it starts scrolling to the left. It's a simple matter of using a timer and calling graphics.drawText while reducing the X value each frame.Last edited by Andiamo; 11-28-09 at 09:50 PM.
11-28-09 08:53 PMLike 0 - Sorry, I won't paste code because it is part of a custom ObjectListField class that has a LOT of other code in it.
However, it is not difficult to achieve. First, create a new class that extends ObjectListView. Create an integer instance variable called scrollXPosition... this will keep track of the position of the scroller. Create a new Timer and have the Timer decrement the value of scrollXPosition each tick, then call invalidate(). In your drawListRow method, replace the graphics.drawText() at the end of the method with...
Code:graphics.drawText(rowString.toString(), scrollXPosition, y, 0, w);
However there are some other things you'll need to solve, including:
1) The logic that decides when to start and stop the Timer
2) When the user selects a different item, reset scrollXPosition to 0
3) When the text goes completely off the screen, reset scrollXPosition to 0
Good luck!12-02-09 04:49 PMLike 0
- Forum
- BlackBerry Developers
- Developers Lounge
How to do Text Wrapping for text in List Field with Checkboxes ?
LINK TO POST COPIED TO CLIPBOARD