redline
redline

Reputation: 224

How to Change Font Size of Text in ListField?

In drawListRow() method, I draw texts using graphics.drawText(). How can I change the font size of text?

Upvotes: 0

Views: 861

Answers (2)

wmorrison365
wmorrison365

Reputation: 6318

Have you tried first setting the Graphics#setFont with your newly sized font?

Perhaps using Font#derive(style, size):

http://www.blackberry.com/developers/docs/4.3.0api/net/rim/device/api/ui/Font.html#derive(int,%20int)

Just quickly perused the javadocs, not actually done this. something like:

font myFont8 = ...;

Font myFont16 = myFont8.derive((myFont8.getStyle(), 16);

g.setFont(myFont16);

g.drawText(...);

Upvotes: 2

Swati
Swati

Reputation: 52847

In your ListFieldCallback code, override drawListRow() and set the Font there:

public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
    Font myFont= FontFamily.forName(FontFamily.FAMILY_SYSTEM).getFont(fontStyle,
        fontSize);
    g.setFont(myFont);
    g.drawText(str, 0, y, DrawStyle.TOP|DrawStyle.LEFT, w);
}

Upvotes: 3

Related Questions