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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 96
Registered: ‎06-11-2009
My Device: Not Specified
Accepted Solution

Custom ListField

Hello All,

 

I am currently porting an existing Jme application to BB using the native api(JDE 4.6).I currently have a list which is rendered as shown in the attached image . Could someone kindly guide me as to how i achieve the same using the List field or the possible way of acheiving the same. Thanks in advance.

 

My List

 

 

 

 

Thanking you,

Regards,

S.A.Norton Stanley

 

Highlighted
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Custom ListField

a few steps: set the rowheight to an appropriate value (font * 2 + x)
create the draw callback.
in drawListRow you have three elements:
a bitmap, use drawBitmap to paint the colored ball.
drawText 1, and drawText 2
use y+... to adjust the drawing in the line.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 96
Registered: ‎06-11-2009
My Device: Not Specified

Re: Custom ListField

Hi Simon,

Thank you. Ill try the same.

 

Regards,

S.A.Norton Stanley

Developer
Posts: 96
Registered: ‎06-11-2009
My Device: Not Specified

Re: Custom ListField

Hello,

 

In my drawListRow method in order to achieve two lines i do the following:

 

  StringBuffer stringBuffer=new StringBuffer();
  stringBuffer.append(firstLine).append('\n').append(secondLine);

  g.drawText(stringBuffer.toString(),width, y, 0, w);

 

but i never see a new line being added.The first line and second line appear together. Am i doing something wrong here?

 

Thanking you,

Regards,

S.A.Norton Stanley

Developer
Posts: 137
Registered: ‎09-30-2009
My Device: Torch 9800

Re: Custom ListField

You have to use two drawtext function call. One with the first line. Then draw the second line in another drawtext by changing the y appropriately.
----------------------
Press like if you find a message helpful
---------
Developer
Posts: 96
Registered: ‎06-11-2009
My Device: Not Specified

Re: Custom ListField

[ Edited ]

Hi,
Thank you. I achieved it using the following :
g.drawText(firstLine,width, y, 0, w);
g.drawText(secondLine, y+g.getFont().getHeight(), 0, w);

 

And also to point out the drawText method does not handle new-lines, which i figured out later.


Regards,
S.A.Norton Stanley