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
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone
Accepted Solution

Nasty problem with resizing a list and custom CellRenderer

I create a list (_myList) in a separate class with a custom CellRenderer. In the custom CellRenderer I draw a rectangle with a gradient in the data() function:

override public function set data (value:Object) : void
{
	super.data = value;
		
	var tab_color:Array = this.data.rowColor;
	...
	_matrix.createGradientBox(this.width, this.height, 90/180*Math.PI);
		
	with (_sprTab.graphics)
	{
		clear();
		beginGradientFill(GradientType.LINEAR, [tab_color[0], tab_color[1], tab_color[2]], [alpha,alpha,alpha], [0,127,255], _matrix);
		drawRoundRectComplex(0, 0, this.width, this.height, 15, 0, 15, 0);
		endFill();
	}	
	...
}

When orientation changes I want to resize the list. Therefore, in a function in the class in which the list is created I resize the list:

public function setListSize (w:Number, h:Number) : void
{
	_myList.setSize(w, h);
}

And this function is called with the new dimensions on orientation change, in the main class.

However, this.width in the custom CellRenderer does not get the new list width for some reason.

Any idea why?

Eugene

My PlayBook App: Checklists
Developer
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: Nasty problem with resizing a list and custom CellRenderer

There is one thing I need to add: when _myList is created the size is set to 200 pixels:

with (_myList)
{
	rowHeight = MyConstants.TAB_HEIGHT;
	setSize(MyConstants.TAB_WIDTH_LANDSCAPE, MyConstants.STAGE_HEIGHT_LANDSCAPE);
	setSkin(MyCellRenderer);
	selectionMode = ListSelectionMode.SINGLE;
	allowDeselect = false;
	addEventListener(ListEvent.ITEM_CLICKED, listItemClickedHandler);
}

So MyConstants.TAB_WIDTH_LANDSCAPE = 200 (set in a separate class);

Resizing the list to a width < 200 works (i.e. the rectangle gets the same size < 200), resizing the list to a width > 200 will keep the rectangle at 200 pixels. I don't understand this.

Eugene

My PlayBook App: Checklists
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Nasty problem with resizing a list and custom CellRenderer

You need to refresh the visible items in the list. You can loop thru the list and call replaceItem(...) and that should do it. You can verify that this would work by scrolling the list to unseen items and they should have picked up the new width.
Developer
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: Nasty problem with resizing a list and custom CellRenderer

John, fantastic. I now reload the list items after an orientation change and that works. Man, caused me a headache.
Eugene

My PlayBook App: Checklists