12-06-2010 04:22 PM
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.
12-06-2010 04:30 PM
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
12-06-2010 04:54 PM - edited 12-06-2010 04:55 PM
Hahaa true!....I should just be happy it's working
...I'm going to start pointing fingers at ActionScript's end....lol ![]()
12-07-2010 08:57 AM
@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.
12-07-2010 10:50 AM
12-07-2010 04:13 PM
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!
12-07-2010 11:49 PM
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!
12-08-2010 12:49 AM - edited 12-08-2010 12:51 AM
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!
12-08-2010 10:59 AM
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!
12-08-2010 11:04 AM
Hey Jimmy,
No problem at all. thats what the forums are here for!
if you have any more questions later on feel free to ask. good luck!