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
Contributor
jimmyd25
Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

Re: Format large text blocks to fit qnx list

hey J Rab.

 

Ya I think it has to do with the fact that I'm populating my list with dynamic content and the structure is a bit different from your example. I think that accounts for why it didn't work for me. I'm still new to this and I'm learning and trying to understand why things work the way they do. In anycase, I guess it's my code that is at fault. Thank you though for the update.

 

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Format large text blocks to fit qnx list

lol if its working for you than its not at fault. if anything its prolly one of those crazy happenings on ActionScript's end. they would refer to this as a "feature" haha

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Contributor
jimmyd25
Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

Re: Format large text blocks to fit qnx list

[ Edited ]

Hahaa true!....I should just be happy it's working :smileyhappy:...I'm going to start pointing fingers at ActionScript's end....lol :smileytongue:

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Format large text blocks to fit qnx list

@jrab:  Have you tried the methods in DataProvider to remove and add new items?  It seems that since the DataProvider was already allocated to the list, you should be able to act on the myList.dataProvider instead of reallocating another DataProvider each time.  Dont know how either way would effect GC over time.  Just a thought.  Since you have a nice little test application here, just curious if DataProvider methods behave as the API indicates.

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Format large text blocks to fit qnx list

I agree. I wasn't really going for efficiency just quick and dirty to see of the removeAll functions the way its supposed to. I think I'd go about this by setting up the dataprovider as a variable so it isn't running wild like the way it is hah. Ill test it out and let you know. Thanks for the heads up!
J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Contributor
jimmyd25
Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

Re: Format large text blocks to fit qnx list

I'm still having a bit of trouble getting items in the list to wordwrap properly according to the renderrer size. J Rab. I remember you mentioning to extend the cell renderer and create a label within it to contain list contents and then setting the label property to wordWrap = true. I have the general idea down, but I don't think i'm implementing it correctly.

 

I have something along the lines of:

 

public class CustomCellRenderer extends CellRenderer

{

public function CustomCellRenderer()

 

var myText:TextField = new TextField();

myText.wordWrap = true;

myText.width = 100;

myText.height =40;

}

 

Now that basically matches the cell renderrer size, however I don't know how to get this label to display within the renderer properly and display all the list contents accordingly. Everytime I execute, all I get is a blank screen on the sim.

 

Any help or nudge in the right direction is appreciated....ty!

 

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Format large text blocks to fit qnx list

hey jimmy,

 

sorry i've been out all day. here's the code i've been working on so far a custom cell renderer with wordwraping:

 

 

package
{
	import flash.text.TextFieldAutoSize;
	
	import qnx.ui.listClasses.AlternatingCellRenderer;
	
	public class MyCustomCellRenderer extends AlternatingCellRenderer
	{
		public function MyCustomCellRenderer()
		{
			super();
		}
		override protected function onAdded():void
		{
			super.onAdded();
			this.label.autoSize = TextFieldAutoSize.LEFT;
			this.label.wordWrap = true;

		}
	}
}

 

 

now i say so far because when it applies the wordwrap the height of hte row isnt automatically adjusted so some of the words are cut off  and cant be seen height-wise. but here's what it it consists of:

 

what i've found is that when you are doing a cellrenderer extension the only function you have to work on is the onAdded() function within the class. That is activated whenever a row of data show up on screen. Also that method lets you access the this.data.label object which is the text you see on screen an it's of a QNX Label object type. so from there you an edit how it looks. you can copy and paste and run it to see hwo it looks in your program. but if the line of text is really long and gets broken from any more than three lines it starts chopping off words. im working on a way to dynamically adjust the height. ill get back to you. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Format large text blocks to fit qnx list

[ Edited ]

Hey Jimmy,

 

ok so from i've found out is that the rowHeight property can only be set for all rows and not just one at a time so it cant be customized on a per row basis. you can adjust the rowHeight to accommadate for more room but if say a row of text is small enough to fit on just one row it may come out weird looking with a lot of space. but woud still get the job done.

 

however i propose another idea. instead of wordwrapping how about cutting the row of text off at the point where it starts disappearing? So if a row of text is too long you'd cut it off via code and put the leading dots at the end (e.g. "Some long text...").

 

here's the Customer CellRenderer class to do just that:

 

 

package
{
	import flash.text.TextFieldAutoSize;
	
	import qnx.ui.listClasses.AlternatingCellRenderer;
	
	public class MyCustomCellRenderer extends AlternatingCellRenderer
	{
		public function MyCustomCellRenderer()
		{
			super();
		}
		override protected function onAdded():void
		{
			super.onAdded();
			
			/*
			 * If the width of the text (in pixels) is larger than the width 
			 * of the cell perform the cut off
			*/
			if (this.label.textWidth > this.width)
			{
				/*
				* Get the character per pixel (charPerPixel) value to use later when
				* we want to calculate how many MAX characters can show up in one row.
				*/
				var charPerPixel:Number = this.label.text.length / this.label.textWidth;
				
				/*
				* Calculate the max amount of characters to show on screen.
				* - 3 to accomodate for the leading dots (...)
				*/
				var charMax:int = Math.floor(charPerPixel * this.width) - 3;
				
				this.label.text = this.label.text.substr(0,charMax) + "...";
			}
			
		}
	}
}

 

 

 

lemme know what you do! good luck!

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Contributor
jimmyd25
Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

Re: Format large text blocks to fit qnx list

hey J Rab. - this method worked perfectly for me. I just wasn't sure how to associate the label with the cell renderer, but you pointing me in the right direction with the onAdded feature saved me. This also helped me format a lot of other things including colors to make my app look a lot better, so I really appreciate the help!

 

As far as the text length goes and cutting the text, I think i'm going to have to try that out next when the content I am feeding in begins getting really long. I'm probably going to be using the method you described to do that as well.

 

Once again thank you for the help!

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Format large text blocks to fit qnx list

Hey Jimmy,

 

No problem at all. thats what the forums are here for! :smileyhappy: if you have any more questions later on feel free to ask. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.