| Package | qnx.fuse.ui.listClasses |
| Class | public class AlternatingCellRenderer |
| Inheritance | AlternatingCellRenderer CellRenderer SkinnableComponent UIComponent flash.display.MovieClip |
AlternatingCellRenderer class is the default cell renderer for the List class.
As the name suggests, AlternatingCellRenderer renders the cells in the list using alternating row colors, such that
each adjacent row uses a different color.
See also
| Method | Defined By | ||
|---|---|---|---|
Creates a new AlternatingCellRenderer instance. | AlternatingCellRenderer | ||
![]() | childChanged(resizedChild:DisplayObject = null):Boolean
Notifies the UIComponent that one or more of its children has changed in a manner
that may affect this object's layout. | UIComponent | |
![]() | destroy():void
Call this method when you want to have your object collected by the garbage collector. | UIComponent | |
![]() | getSizeOptions():int | UIComponent | |
![]() | getTextFormatForState(textState:String):TextFormat
Returns the TextFormat object for a specified state. | CellRenderer | |
![]() | invalidateDisplayList():void
Calling this method results in a call to the components validateDisplayList() method before the display list is rendered. | UIComponent | |
![]() | invalidateProperties():void
Calling this method results in a call to the components validateProperties() method before the display list is rendered. | UIComponent | |
![]() | measure(availableWidth:Number, availableHeight:Number):LayoutMeasurement | UIComponent | |
![]() | setActualSize(w:Number, h:Number):void
Sets the width and height of the object without setting
the explicitWidth and explicitHeight. | UIComponent | |
![]() | setLayoutBounds(bounds:Rectangle):void
Sets the receiver's size and location to the rectangular area specified
by the arguments. | UIComponent | |
![]() | setPosition(x:Number, y:Number):void
Sets the x and y position of the component. | UIComponent | |
![]() | setSkin(newSkin:Object):void
Set the skin object on the component for it to render. | SkinnableComponent | |
![]() | setTextFormatForState(format:TextFormat, textState:String):void
Sets the TextFormat object for the label of a given state. | CellRenderer | |
![]() | validateDisplayList():void
Validates the display list of the component by calling the updateDisplayList(). | UIComponent | |
![]() | validateNow():void
Validates the component immediately by calling validateProperties(), validateSizes(), and validateDisplayList() if necessary. | UIComponent | |
![]() | validateProperties():void
Validates the properties of the component by calling the commitProperties() method. | UIComponent | |
| AlternatingCellRenderer | () | Constructor |
public function AlternatingCellRenderer()
Creates a new AlternatingCellRenderer instance.
In the following example, a custom AlternatingCellRenderer class is created in order to place a check box component
inside of each cell. The AlternatingCellRenderer is used to display grocery items. The class contains event listeners
to provide custom processing for mouse click events.
package
{
import flash.events.Event;
import flash.events.MouseEvent;
import qnx.fuse.ui.buttons.CheckBox;
import qnx.fuse.ui.listClasses.AlternatingCellRenderer;
public class MyCustomCellRenderer extends AlternatingCellRenderer
{
private var myCB:CheckBox;
public function MyCustomCellRenderer()
{
}
override protected function init():void
{
super.init();
myCB = new CheckBox();
myCB.x = 250;
myCB.y = 10;
this.addChild(myCB);
myCB.addEventListener( MouseEvent.CLICK, onClick );
//add this listener in order to block the mouse down event from the list
//see the onMouseDown method to see how to stop the event propagation
myCB.addEventListener( MouseEvent.MOUSE_DOWN, onMouseDown);
}
//this will prevent the cell from being selected when the button is clicked down
private function onMouseDown(event:MouseEvent):void
{
event.stopImmediatePropagation();
}
private function onClick(event:MouseEvent):void
{
dispatchEvent( new Event( Event.SELECT, true, true ) );
}
}
}
The following sample application calls the custom AlternatingCellRenderer class that is listed above.
package
{
import flash.display.Sprite;
import qnx.ui.data.DataProvider;
import qnx.fuse.ui.listClasses.List;
import qnx.fuse.ui.listClasses.ListSelectionMode;
[SWF(height="600", width="1024",
frameRate="30", backgroundColor="#FFFFFF")]
public class CustomListSample extends Sprite
{
public function CustomListSample()
{
initializeUI();
}
private function initializeUI():void
{
var arrItems:Array=[];
arrItems.push({label: "Apples"});
arrItems.push({label: "Potatoes"});
arrItems.push({label: "Oranges"});
arrItems.push({label: "Tomatoes"});
arrItems.push({label: "Carrots"});
arrItems.push({label: "Eggplant"});
arrItems.push({label: "Celery"});
arrItems.push({label: "Milk"});
arrItems.push({label: "Ham"});
arrItems.push({label: "Cheese"});
arrItems.push({label: "Bacon"});
var myList:List = new List();
myList.setPosition(100, 200);
myList.width = 300;
myList.height = 300;
myList.selectionMode = ListSelectionMode.MULTIPLE;
myList.dataProvider = new DataProvider(arrItems);
myList.cellRenderer = MyCustomCellRenderer;
this.addChild(myList);
}
}
}