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
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: How to draw mutli line text in the listfield? use drawText method

I have data like this:" I like to play Football"
I want that it should be displayed like:

I like
to play Football
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to draw mutli line text in the listfield? use drawText method

And your current code in your drawListRow does what?

Developer
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: How to draw mutli line text in the listfield? use drawText method

here is my code:
g.drawText("I like to play Football", 20, y, 0, w);
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to draw mutli line text in the listfield? use drawText method

OK so split your String into two parts, and have two different drawTexts with two different y values.  See Simon's post for more. 

Developer
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: How to draw mutli line text in the listfield? use drawText method

What if i am getting that string from a web?
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to draw mutli line text in the listfield? use drawText method

Doesn't make any differenc does it?  You still have to split the String and display on separate lines?

 

If you want to 'word wrap, search the forum there are a number of Threads that talk about doing this. 

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

Re: How to draw mutli line text in the listfield? use drawText method

If you need to display a string you get from an external source and suspect that it might not fit on one line or if it contains newline characters you'd like to honor, you will have to split the string into multiple ones and use multiple drawText calls with varying y values.

Of course, creating your own word-wrapping mechanism is not the easiest thing in the world, but it can be done. Start by looking at Font.getAdvance methods.

 

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