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
Posts: 80
Registered: ‎09-03-2012
My Device: 9810
My Carrier: Vodafone

ActiveRichTextField does not shows expected formatting in device(Torch 9810) but works on simulator (9530).

I am creating an ActiveRichTextField with formatted substrings from a provided String on whose click there will be some action.

 

The provided string is :

 

private static final String HELP_STR = "Should you have questions or concerns please visit the FAQs section of www.samplesoffers.com, email us at help@samplesoffersme.com, or call us at 1.800.425.3720.";


There are four text regions that need to be formatted ::

1. FAQs   -> Bold and Black Coloured Font
2. www.samplesoffers.com    ->  Underlined and BLUE Coloured Font.
3. help@samplesoffersme.com   ->  Underlined and BLUE Coloured Font.
4. 1.800.425.3720   ->  Underlined and BLUE Coloured Font.

For implmenting above functionality, I have written the following :

 

public final class HelpProScreen extends MainScreen
{
	private ActiveRichTextField mActiveRichTextField = null;
	private static final String HELP_STR = "Should you have questions or concerns please visit the FAQs section of www.samplesoffers.com, email us at help@samplesoffersme.com, or call us at 1.800.425.3720.";
	
	public HelpProScreen()
	{
		mActiveRichTextField = new ActiveRichTextField(HELP_STR, new int[]{0, 55, 59, 71, 92, 106, 130, 146,
				HELP_STR.length()}, new byte[]{0, 1, 0, 2, 0, 2, 0, 2}, new Font[]{Font.getDefault(),
				Font.getDefault().derive(Font.BOLD), Font.getDefault().derive(Font.UNDERLINED)}, new int[]{Color.BLACK,
				Color.BLACK, Color.BLUE}, null, 0);
	
		add(mActiveRichTextField);
	}
}

 

In simulator 9530 I am getting result as expected, but while running it on Torch 9810 there occurs a problem.

 

The complete text is black coloured and FAQs region does not  have BOLD appearance.
Though underline Font appears for region 2, 3 and 4 but Foreground color Blue does not appears for them.

 

9530.jpg

 

Simulator Snapshot (Expected ScreenView). 

Any Help ?

 

Always Success
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: ActiveRichTextField does not shows expected formatting in device(Torch 9810) but works on simulator (9530).

I would suspect a different ActiveRichTextField handling for 9530 and 9810. The system has its own handling for stuff which is recognized as URL or e-mail address as well as phone number. Do you see different results if you remove the formatting and let ActiveRichTextField define zones on its own?

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 80
Registered: ‎09-03-2012
My Device: 9810
My Carrier: Vodafone

Re: ActiveRichTextField does not shows expected formatting in device(Torch 9810) but works on simulator (9530).

Thank you very much arkadyz for your reply.

 

I was trying to use this ActiveRichTextField for displaying above composite text.

 

Actually I was unaware of the fact that ActiveRichTextField was capable of handling text itself for URL's , email addresses etc.

 

And now changed initialization code is :

 

mActiveRichTextField = new ActiveRichTextField(HELP_STR);
		mActiveRichTextField.setAttributes(new int[]{Color.BLACK, Color.RED, Color.BLACK, Color.RED, Color.BLACK,
				Color.RED}, null);

 that results in no change view in Torch 9810(device) .and also generated the same view for simulator (9530).


Will overriding paint()  in any way help out the task ?

 

 

 

 

Always Success
Highlighted
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: ActiveRichTextField does not shows expected formatting in device(Torch 9810) but works on simulator (9530).

Don't even try overriding paint() there - I'm pretty sure it's very complicated and tightly coupled with the field's layout(), so you'll just ruin everything.

 

Take a look at drawText (not the deprecated one, but the one inherited from TextField) and see what parameters you get there. Make it just call super.drawText for now, put a break point and observe. That's how I would start if I needed to change the field's behavior.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!