如何在Blackberry中将部分文本设置为LabelField的粗体字体?

时间:2015-01-30 09:27:06

标签: blackberry

我不知道如何将部分文本设置为Blackberry中的LabelField粗体。

请参阅附图,

enter image description here

1 个答案:

答案 0 :(得分:1)

This示例应该包含您需要的所有内容。您的代码应如下所示:

        String copyText = "Tap NEXT to proceed";
        Font[] fonts = new Font[2];
        fonts[0] = Font.getDefault();
        fonts[1] = Font.getDefault().derive(Font.BOLD);

        int[] offsets = new int[4];
        offsets[0] = 0;
        offsets[1] = "Tap ".length
        offsets[2] = "Tap NEXT".length;
        offsets[3] = copyText.length();

        byte[] attributes = new byte[3];
        attributes[0] = 0;
        attributes[1] = 1;
        attributes[2] = 0;

        RichTextField textField = new RichTextField(copyText, offsets, attributes, fonts, NON_FOCUSABLE);
        add(textField);