qnx.ui.listClasses.AlternatingCellRenderer

AlternatingCellRenderer

Properties | Methods | Examples


Packageqnx.ui.listClasses
Classpublic class AlternatingCellRenderer
InheritanceAlternatingCellRenderer Inheritance CellRenderer Inheritance SkinnableComponent Inheritance UIComponent Inheritance flash.display.MovieClip

The 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.



Class information:
PlayBook Tablet OS Version:   1.0.6

View the examples

See also

CellRenderer
List



Public Properties

 PropertyDefined By
 Inheritedcolumn : int
Gets or sets the column of the cell.
CellRenderer
 Inheritedcontainment : String
Gets or sets a property that determines how a component is contained within a parent container.
UIComponent
 Inheriteddata : Object
Gets or sets the data object for the cell renderer.
CellRenderer
 Inheritedindex : int
Gets or sets the index of the cell.
CellRenderer
 InheritedisHeader : Boolean
[read-only] Returns a Boolean indicating whether or not the cell is a header.
CellRenderer
 Inheritedrow : int
Gets or sets the row of the cell.
CellRenderer
 Inheritedsection : int
Gets or sets the section of the cell.
CellRenderer
 Inheritedsize : Number
Gets or sets the size for this component (as a percentage of the container's size, or in pixels).
UIComponent
 InheritedsizeMode : String
Gets or sets the size mode for this component.
UIComponent
 InheritedsizeUnit : String
Gets or sets the unit of measure for the size property.
UIComponent
 Inheritedstate : String
Gets or sets the state of the cell.
CellRenderer

Public Methods

 MethodDefined By
  
Creates a new AlternatingCellRenderer instance.
AlternatingCellRenderer
 Inherited
destroy():void
Call this method when you want to have your object collected by the garbage collector.
UIComponent
 Inherited
drawNow():void
Calls the draw() method.
UIComponent
 Inherited
getTextFormatForState(state:String):TextFormat
Returns the TextFormat object for a specified state.
CellRenderer
 Inherited
invalidate(property:String = all, invalidateNow:Boolean = false):void
Marks the property as invalid and the draw() method is called on the next frame or the next render, whichever comes first.
UIComponent
 Inherited
setPosition(x:Number, y:Number):void
Sets the x and y position of the component.
UIComponent
 Inherited
setSize(w:Number, h:Number):void
[override] Sets the width and height of the component.
CellRenderer
 Inherited
setSkin(cellSkin:Object):void
Set the skin object on the component for it to render.
SkinnableComponent
 Inherited
setTextFormatForState(format:TextFormat, state:String):void
Sets the TextFormat object for the label of a given state.
CellRenderer

Protected Methods

 MethodDefined By
 Inherited
callLater(method:Function):void
Calls the specified method on the next frame or the next render, which ever happens first.
UIComponent
 Inherited
createInstance(linkage:Object):DisplayObject
Calling this method will attempt to create a DisplayObject instance based on the value of the linkage parameter.
UIComponent
 Inherited
draw():void
Called every time you set the width and height of the component.
UIComponent
 Inherited
isInvalid(property:String, ... properties):Boolean
Checks to see if the property is invalid and returns true if it is.
UIComponent
 Inherited
onAdded():void
Called when the instance is added to the stage.
UIComponent
 Inherited
onRemoved():void
Called when the instance is removed from the stage.
UIComponent
 Inherited
setEnabled(val:Boolean):void
Called when the enabled property changes.
UIComponent
 Inherited
validate(property:String = all):void
Lets the component know that the specified property has been validated.
UIComponent

Constructor Detail

AlternatingCellRenderer()


public function AlternatingCellRenderer()

Creates a new AlternatingCellRenderer instance.

Examples

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.ui.buttons.CheckBox;
    import qnx.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.ui.listClasses.List;
    import qnx.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.setSkin(MyCustomCellRenderer);
            
            this.addChild(myList);
        }
    }
}