| Package | qnx.ui.listClasses |
| Class | public class SectionList |
| Inheritance | SectionList List UIComponent flash.display.MovieClip |
| Subclasses | SectionTileList |
SectionList class allows you to group sections of data in a list.
For example, you can group a list of contacts based on the letters in the alphabet.
You can provide custom headers for your list by calling the setHeader method.
Your header must set the ICellRenderer.isHeader to true.
The following image shows a basic SectionList instance.
See also
| Property | Defined By | ||
|---|---|---|---|
![]() | allowDeselect : Boolean
Determines if a selected cell in the list can be deselected when pressed. | List | |
![]() | columnWidth : int
Gets or sets the width of each column in the list. | List | |
![]() | containment : String
Gets or sets a property that determines how a component is contained within a parent container. | UIComponent | |
| dataProvider : IDataProvider [override]
Gets or sets the DataProvider for the list. | SectionList | ||
![]() | enableShadows : Boolean
Sets or gets whether the scroll shadows should be shown. | List | |
![]() | firstVisibleItem : ICellRenderer [read-only]
Returns the first visible item in the view port area as defined by the width and height
| List | |
![]() | footerView : DisplayObject
Gets or sets the footer view. | List | |
| headerHeight : int
Gets or sets the height of the header (in pixels). | SectionList | ||
| headerWidth : int
Gets or sets the width of the header (in pixels). | SectionList | ||
![]() | lastVisibleItem : ICellRenderer [read-only]
Returns the last visible item in the view port area as defined by the width and height
| List | |
![]() | rowHeight : int
Gets or sets the height of each row in the list. | List | |
![]() | scrollable : Boolean
Gets or sets a value that determines whether a list can be scrolled. | List | |
![]() | scrollBarAlpha : Number
Gets or sets the opacity value for the scroll bar on the list. | List | |
![]() | scrollBarColor : Number
Gets or sets the color of the scroll bar. | List | |
![]() | scrollBarOffset : int
Gets or sets the x or y postion of the scrollbar, in pixels. | List | |
![]() | scrollDirection : String
Gets and sets the scroll direction of the list. | List | |
| selectedIndex : int [override]
Setting the selectedIndex property will have no effect on the list and will cause an error to be thrown. | SectionList | ||
| selectedIndices : Array [override]
Setting the selectedIndices property will have no effect on the list and will cause an error to be thrown. | SectionList | ||
![]() | selectedItem : Object
Gets or sets the currently selected item in a single-selectable list. | List | |
![]() | selectedItems : Array
Gets or sets the group of selected items (selectedItems) in a multi-selectable list. | List | |
![]() | selectionMode : int
Gets or sets a value that determines whether or not selection mode is enabled. | List | |
![]() | size : Number
Gets or sets the size for this component (as a percentage of the
container's size, or in pixels). | UIComponent | |
![]() | sizeMode : String
Gets or sets the size mode for this component. | UIComponent | |
![]() | sizeUnit : String
Gets or sets the unit of measure for the size property. | UIComponent | |
| Method | Defined By | ||
|---|---|---|---|
Creates a new SectionList instance. | SectionList | ||
addChildToIndex(item:Object, index:int):void
Appends a child item to a section in the list, given the index of the section. | SectionList | ||
addChildToIndexAt(item:Object, index:int, childindex:int):void
Adds a child item to a section at a specified index. | SectionList | ||
![]() | addItem(item:Object):void
Appends an item to the end of the list. | List | |
![]() | addItemAt(item:Object, index:int):void
Adds an item to the list at the specified index. | List | |
![]() | addItemsAt(items:Array, index:int):void
Adds an array item at the specified index. | List | |
![]() | destroy():void
Call this method when you want to have your object collected by the garbage collector. | UIComponent | |
![]() | drawNow():void
Calls the draw() method. | UIComponent | |
![]() | getIsCellVisibleAtIndex(index:int):Boolean
Returns a Boolean indicating whether or not a cell at a given index is visible in the virtual area. | List | |
![]() | getItemAt(index:int):Object
Returns the item in the DataProvider at the specified index. | List | |
![]() | invalidate(property:String, 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 | |
![]() | removeAll():void
Removes all the items from the list. | List | |
removeAllChildrenFromIndex(index:int):void
Removes all child items from a section at the specified index. | SectionList | ||
removeChildFromIndexAt(index:int, childindex:int):void
Removes a child item from a section at a specified index. | SectionList | ||
![]() | removeItem(item:Object):void
Removes a given item from the list. | List | |
![]() | removeItemAt(index:int):void
Removes an item from list at the specified index. | List | |
replaceChildInIndexAt(index:int, item:Object, childindex:int):void
Replaces a child item in a section at a specified index. | SectionList | ||
![]() | replaceItem(item:Object, oldObject:Object):void
Replaces an item, given the new item object and the old item. | List | |
![]() | replaceItemAt(item:Object, index:int):void
Replaces the item in the list at the specified index with a new item. | List | |
scrollIndexVisible(index:int, seconds:Number = 1):void [override]
Scrolls a given item into view, given an index and an animation duration (in seconds). | SectionList | ||
scrollToIndex(index:int, seconds:Number = 1):void [override]
Animates the section into view so that the header is at the top of the list. | SectionList | ||
scrollToIndexInSection(section:int, index:int, seconds:int = 1):void
Animates the child of a section into view. | SectionList | ||
setHeaderSkin(skin:Object):void
Sets the header renderer skin. | SectionList | ||
![]() | setPosition(x:Number, y:Number):void
Sets the x and y position of the component. | UIComponent | |
![]() | setSize(w:Number, h:Number):void
Sets the width and height of the component. | UIComponent | |
![]() | setSkin(skin:Object):void
Sets the cell renderer to use to populate the list. | List | |
updateChildInIndexAt(index:int, item:Object, childindex:int):void
Updates an item in a section at a specified index. | SectionList | ||
![]() | updateItem(value:Object, oldObject:Object):void
Updates an item in the list, given the new item and the item to update. | List | |
![]() | updateItemAt(item:Object, index:int):void
Updates the item in the list at the specified index, given the new item. | List | |
![]() | updateItemsAt(items:Array, index:int):void
Updates the items starting at the specified index with new items. | List | |
| dataProvider | property |
dataProvider:IDataProvider[override]
Gets or sets the DataProvider for the list.
Unlike the List class, the dataProvider property for the SectionList class
must be of type ISectionDataProvider class.
public function get dataProvider():IDataProvider public function set dataProvider(value:IDataProvider):void| headerHeight | property |
headerHeight:intGets or sets the height of the header (in pixels).
The default value is 24.
public function get headerHeight():int public function set headerHeight(value:int):void| headerWidth | property |
headerWidth:intGets or sets the width of the header (in pixels).
The default value is 100.
public function get headerWidth():int public function set headerWidth(value:int):void| selectedIndex | property |
selectedIndex:int[override]
Setting the selectedIndex property will have no effect on the list and will cause an error to be thrown.
Use selectedItem instead.
public function get selectedIndex():int public function set selectedIndex(value:int):voidError — An error stating the selectedIndices cannot be set.
|
| selectedIndices | property |
selectedIndices:Array[override]
Setting the selectedIndices property will have no effect on the list and will cause an error to be thrown.
Use selectedItems instead.
public function get selectedIndices():Array public function set selectedIndices(value:Array):voidError — An error stating the selectedIndices cannot be set.
|
| SectionList | () | Constructor |
public function SectionList()
Creates a new SectionList instance.
| addChildToIndex | () | method |
public function addChildToIndex(item:Object, index:int):voidAppends a child item to a section in the list, given the index of the section.
Parameters
item:Object — The child item to add to the list.
| |
index:int — The index of the section for which to add the child item.
|
| addChildToIndexAt | () | method |
public function addChildToIndexAt(item:Object, index:int, childindex:int):voidAdds a child item to a section at a specified index.
Parameters
item:Object — The child item to add.
| |
index:int — The index of the section for which to add the child item.
| |
childindex:int — The index of the child item in the section.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
| |
RangeError — thrown if the specified childindex is less than 0 or greater than or equal to the length of the section.
|
| removeAllChildrenFromIndex | () | method |
public function removeAllChildrenFromIndex(index:int):voidRemoves all child items from a section at the specified index.
Parameters
index:int — The index of the section.
|
| removeChildFromIndexAt | () | method |
public function removeChildFromIndexAt(index:int, childindex:int):voidRemoves a child item from a section at a specified index.
mySectionList.removeChildFromIndexAt(1, 30);
mySectionList.removeChildFromIndexAt(1, 29);
mySectionList.removeChildFromIndexAt(1, 28);
Parameters
index:int — The index of the section.
| |
childindex:int — The index of the child in the section.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
| |
RangeError — thrown if the specified childindex is less than 0 or greater than or equal to the length of the section.
|
| replaceChildInIndexAt | () | method |
public function replaceChildInIndexAt(index:int, item:Object, childindex:int):voidReplaces a child item in a section at a specified index.
Parameters
index:int — The index of the section.
| |
item:Object — The new child item.
| |
childindex:int — The index of the child item in the section.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
| |
RangeError — thrown if the specified childindex is less than 0 or greater than or equal to the length of the section.
|
| scrollIndexVisible | () | method |
override public function scrollIndexVisible(index:int, seconds:Number = 1):voidScrolls a given item into view, given an index and an animation duration (in seconds).
This function checks to see if the cell is currently visible before scrolling it into view. If the cell is not fully visible within the viewport of the list, it will scroll it into the viewport. If the cell is fully visible in the viewport, the list will not scroll.
Parameters
index:int — The index of the cell to animate into view.
| |
seconds:Number (default = 1) — The duration of the animation in seconds. Default is 1 second.
|
| scrollToIndex | () | method |
override public function scrollToIndex(index:int, seconds:Number = 1):voidAnimates the section into view so that the header is at the top of the list.
Parameters
index:int — The index of the section for which to animate.
| |
seconds:Number (default = 1) — The duration of the animation in seconds. Default is 1 second.
|
| scrollToIndexInSection | () | method |
public function scrollToIndexInSection(section:int, index:int, seconds:int = 1):voidAnimates the child of a section into view.
Parameters
section:int — The section that contains the child.
| |
index:int — The index of the child for which to animate to.
| |
seconds:int (default = 1) — The duration of the animation in seconds. Default is 1 second.
|
| setHeaderSkin | () | method |
public function setHeaderSkin(skin:Object):voidSets the header renderer skin. You can apply a custom header skin to customize the look of each section in the list.
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ICellRenderer interface.
Note: Do not pass in an instance of a skin class. This may cause unexpected behavior.
Parameters
skin:Object |
| updateChildInIndexAt | () | method |
public function updateChildInIndexAt(index:int, item:Object, childindex:int):voidUpdates an item in a section at a specified index.
Parameters
index:int — The index of the section.
| |
item:Object — The new item.
| |
childindex:int — The index of the item in the section.
|
RangeError — thrown if the specified index is less than 0 or greater than or equal to the length of the DataProvider.
| |
RangeError — thrown if the specified childindex is less than 0 or greater than or equal to the length of the section.
|
The following example creates a SectionList instance that contains calendar data.
package
{
import flash.display.Sprite;
import qnx.ui.data.SectionDataProvider;
import qnx.ui.listClasses.SectionList;
[SWF(height="600", width="1024",
frameRate="30", backgroundColor="#FFFFFF")]
public class SectionSample extends Sprite
{
private var mySectionList:SectionList;
public function SectionSample()
{
initializeUI();
normalizeDays();
}
private function initializeUI():void
{
//create and setup section list
mySectionList = new SectionList();
mySectionList.setPosition(100, 50);
mySectionList.width = 300;
mySectionList.height = 500;
mySectionList.headerHeight = 48;
mySectionList.dataProvider = createDataProvider();
this.addChild(mySectionList);
}
private function createDataProvider():SectionDataProvider
{
//populate month name array
var arrMonth:Array=[];
arrMonth.push({label: "January"});
arrMonth.push({label: "February"});
arrMonth.push({label: "March"});
arrMonth.push({label: "April"});
arrMonth.push({label: "May"});
arrMonth.push({label: "June"});
arrMonth.push({label: "July"});
arrMonth.push({label: "August"});
arrMonth.push({label: "September"});
arrMonth.push({label: "October"});
arrMonth.push({label: "November"});
arrMonth.push({label: "December"});
var mySDP:SectionDataProvider = new SectionDataProvider();
//populate section data provider
for( var i:int = 0; i < arrMonth.length; i++ )
{
//add month names
var section:Object = new Object();
section.label = arrMonth[i].label;
mySDP.addItem( section );
//add day numbers, all 31 for now
for( var j:int = 1; j<32; j++ )
{
mySDP.addChildToItem( {label: j}, section );
}
}
return(mySDP);
}
private function normalizeDays():void{
//Remove February Days
//TODO: account for leap years
mySectionList.removeChildFromIndexAt(1, 30);
mySectionList.removeChildFromIndexAt(1, 29);
mySectionList.removeChildFromIndexAt(1, 28);
//Remove April Day
mySectionList.removeChildFromIndexAt(3, 30);
//Remove June Day
mySectionList.removeChildFromIndexAt(5, 30);
//Remove September Day
mySectionList.removeChildFromIndexAt(8, 30);
//Remove November Day
mySectionList.removeChildFromIndexAt(10, 30);
}
}
}