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
technolgia
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

 

Please use plain text.
Developer
simon_hain
Posts: 16,023
Registered: ‎07-29-2008
My Device: Z10 LE
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
Please use plain text.
Developer
technolgia
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

Please use plain text.
Developer
technolgia
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

Please use plain text.
Developer
raquibulbari
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
---------
Please use plain text.
Developer
technolgia
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

Please use plain text.