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

Adobe AIR Development

Reply
Developer
VansFannel
Posts: 166
Registered: ‎03-04-2011
My Device: Playbook

Split a text to show it in a multiline qnx.ui.text.Label

I'm developing an ActionScript 3 app for Playbook.

 

I have an XML file with some texts. One of them is a big string. I want to show it in the following Label:

 

 

var label32:Label = new Label();
label32.setPosition(5, 5);
label32.setSize(100, 100);
label32.multiline = true;
label32.autoSize = TextFieldAutoSize.LEFT;
label32.embedFonts = true;
label32.textField.antiAliasType = AntiAliasType.ADVANCED;
label32.textField.sharpness = 1;
label32.textField.thickness = 25;
label32.textField.gridFitType = GridFitType.PIXEL;
label32.format = instrucTextFormat;
label32.text = loadString(4, getUserLanguage());

 I have added '\n' inside the string to split it, but it doesn't work.

 

If I use html, can I add HTML tags inside an XML file?

 

Any advice?

 

Please use plain text.
Regular Contributor
L7ColWinters
Posts: 82
Registered: ‎11-12-2010
My Device: Android Droid Incredible

Re: Split a text to show it in a multiline qnx.ui.text.Label

[ Edited ]

Since you have a the label to multline = true it will show on multiple lines when you set the width property to a static value. You shouldn't need to put \n or use html.

 

but you should be able to put break tags in the xml just make sure to use the CDATA[ "html" ] when you do it if you choose to use html

Please use plain text.
Developer
ajerman
Posts: 101
Registered: ‎03-18-2011
My Device: Playbook Simulator

Re: Split a text to show it in a multiline qnx.ui.text.Label

I like what L7 said, but there's always the substr function if you want to limit each line to a certain amount of characters. Not as ideal for non-monospaced fonts though. The multiline option is probably the best bet.
Please use plain text.
Developer
berryawesome
Posts: 54
Registered: ‎12-22-2010
My Device: Not Specified

Re: Split a text to show it in a multiline qnx.ui.text.Label

L7 is right. The text will wrap. Still, if you are looking to break the line at a specific point using the new line character you should be able to.

label.text ="line1\nline 2"; will in fact yield:

line1

line2

 

If your text is not wrapping or you still fail to get multiple lines using \n I suggest you at least trace the string to make sure its correct. When tracing it, you should see multiple  lines if using \n. If you do not, then check your string.

Please use plain text.
Developer
VansFannel
Posts: 166
Registered: ‎03-04-2011
My Device: Playbook

Re: Split a text to show it in a multiline qnx.ui.text.Label

I've tried all of yours solutions, and it doesn't work for me.

 

Above, I put the code that it's not working. Multiline doesn't work here and '\n' caracter either.

 

I'm using htmlText with <BR> and works fine.

Please use plain text.
Developer
berryawesome
Posts: 54
Registered: ‎12-22-2010
My Device: Not Specified

Re: Split a text to show it in a multiline qnx.ui.text.Label

glad htmlText is doing the trick for you. You mention your code sample, but there's no way for us to know what your loadString() function is returning which is why I suggested tracing it. If you're content with how it works now then you're all set. 

Just out of curiosity, did you ever trace the output of that function? If so, did you get the line breaks on the console window?

Please use plain text.
Developer
VansFannel
Posts: 166
Registered: ‎03-04-2011
My Device: Playbook

Re: Split a text to show it in a multiline qnx.ui.text.Label

Suppose that loadString() returns a String like this:

 

"function is returning which is why I suggested tracing it. If you're content with how it works now then you're all set. Just out of curiosity, did you ever trace the output of that function? If so, did you get the line breaks on the console window?"

Please use plain text.
Developer
berryawesome
Posts: 54
Registered: ‎12-22-2010
My Device: Not Specified

Re: Split a text to show it in a multiline qnx.ui.text.Label

ok, so where would you insert the '\n' and how were you doing it? 

Please use plain text.
Developer
VansFannel
Posts: 166
Registered: ‎03-04-2011
My Device: Playbook

Re: Split a text to show it in a multiline qnx.ui.text.Label

Don't worry, it's working with htmlText.

 

I'm using \n like this:

function is returning which is why I suggested tracing it. If you're content with how it works now then you're all set.\nJust out of curiosity, did you ever trace the output of that function? If so, did you get the line breaks on the console window?

 

I've added a \n at the beginning of line 2.

Please use plain text.