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
Developer
bcq
Posts: 34
Registered: ‎11-02-2009
My Device: Not Specified

Set font style for invidual text elements in list field!

Hi guys,

 

I want to display rows like this: 

 

I want to achive this!

I am going to sleep!

 

That means i must set font for each element but dynamically way. (i already have the sign (like tags in html) to know what element must be set font).

 

Note: 'cause i have an big amount of data then i can not hard code for single row.

 

Plz let's me know your ideas ~ many thanks.

Please use plain text.
Developer
bikas
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: Set font style for invidual text elements in list field!

You can achieve this using RichTextField.

 

Have a look at this KB article.

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/...

 

Regards

Bikas

Please use plain text.
Developer
Developer
bcq
Posts: 34
Registered: ‎11-02-2009
My Device: Not Specified

Re: Set font style for invidual text elements in list field!

Thank bikas, but I must implement that in List Field

Please use plain text.
Developer
zany
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: Set font style for invidual text elements in list field!

this can be done by implementing the drawListRow() in ListFieldCallBack

 

    public void drawListRow (ListField lstField, Graphics g, int index, int y, int width)
    {

        int xpos;

 

        xpos = g.drawText (msg[0], 0, y);
        g.setFont (Font.getDefault().derive(Font.BOLD));
        xpos = g.drawText (msg[1], xpos+2, y);
        g.setFont (Font.getDefault().derive(Font.ITALIC));
        xpos = g.drawText (msg[2], xpos+2, y);
    }

 

 

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please use plain text.
Developer
Developer
bcq
Posts: 34
Registered: ‎11-02-2009
My Device: Not Specified

Re: Set font style for invidual text elements in list field!

thank zany but i think it's still hard code

Please use plain text.
Developer
zany
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: Set font style for invidual text elements in list field!

Ya, you have hard code the font and list data. May be you can maitain a map between font and list data to avoid hard coding the data if it is possible

.

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Set font style for invidual text elements in list field!

you could put an own markup string into the object and parse it in the listfields draw callback.

or describe the format of the string in additional attributes, similar to css.

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