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
Highlighted
Developer
Posts: 148
Registered: ‎01-08-2013
My Device: 9860
My Carrier: Airtel
Accepted Solution

Set different color and font for different text in Listview

[ Edited ]

Hi all,

 

I want to set  different color and font for different text in Listview row

 graphics.drawText("India", 10, y+6,0,width);
 graphics.drawText("91", 10, y+16,0,width);

 Please help me.

 

 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Set different color and font for different text in Listview

use graphics.setColor.
Also note that you should probably use the font height as an addition to y, not a fixed value (unless you have a fixed font with a height of 10)
----------------------------------------------------------
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: 148
Registered: ‎01-08-2013
My Device: 9860
My Carrier: Airtel

Re: Set different color and font for different text in Listview

Hi simon _hain

 

     I can not understand. Please update the given code.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Set different color and font for different text in Listview

What specifically don't you understand?

 

Look at

graphics.setColor(...)

to set the color and

graphics.setFont(...)

to set the font

 

To find out the height of a Font us ehte

<font>.getHeight()

If the font is the one being used by the Graphics Object at the time, then you can use

grpahics.getFont().getHeight()

 

Hope ths helps.

Developer
Posts: 148
Registered: ‎01-08-2013
My Device: 9860
My Carrier: Airtel

Re: Set different color and font for different text in Listview

[ Edited ]

Hi peter _strange

  

     I acctually want the given bellow type output.

 

 

Country.png

  

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Set different color and font for different text in ListField

You can do this using the code provided above, assuming you have the Fonts defined. 

 

It is relatively easy to create a Font with a different size, look at the derive method of the Font API. 

 

So just create the Font with the size you want, then use the various Graphics methods to set the Font, then drawText to paint the text. 

 

I think that is everything you need.  Give it a go. 

Developer
Posts: 148
Registered: ‎01-08-2013
My Device: 9860
My Carrier: Airtel

Re: Set different color and font for different text in ListField

Hi peter_strange

     

      I can not solve the problem. Please provide source code.

 

 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Set different color and font for different text in ListField

don't you find it a bit rude to ask other developers to do your (i assume) paid work for you, but for free?
----------------------------------------------------------
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: 148
Registered: ‎01-08-2013
My Device: 9860
My Carrier: Airtel

Re: Set different color and font for different text in ListField

 

Please solve my problem. 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Set different color and font for different text in ListField


Sanjit_Patra wrote:

 

Please solve my problem. 


I would not know how, as i have no clue what your problem is, other than a "it does not work".

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