Search code examples
blackberry

How to set partial text as as bold font to LabelField in Blackberry?


I don't know how to set partial text as a Bold to LabelField in Blackberry.

Kindly refer the attached image,

enter image description here


Solution

  • This example should contain everything you'll need. Your code should look something like 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);