Starling Feathers Controls GroupedList

来源:互联网 发布:Ubuntu安装VNC 编辑:程序博客网 时间:2024/05/22 05:05

说明:

The GroupedList class renders groups of items from a hierarchical data source. It includes support for selection, scrolling, custom layouts, layout virtualization, and custom item renderers, similar to the List component.


用法:

因为用到了图标,所以需要下面的代码载入材质

private function loadTextures():void{var appDir:File = File.applicationDirectory;textureAtlas = new AssetManager();textureAtlas.verbose = Capabilities.isDebugger;textureAtlas.enqueue(appDir.resolvePath("textures/"));textureAtlas.loadQueue(assetOnProgress);System.pauseForGCIfCollectionImminent(0);System.gc();}private function assetOnProgress(ratio:Number):void{trace("ratio:",ratio);if (ratio == 1) Starling.juggler.delayCall(initialize, 0.15);}

下面是使用GroupedList的代码

private function testGroupedList():void{var list:GroupedList = new GroupedList();list.dataProvider = new HierarchicalCollection([{header: "Dairy",children:[{ text: "Milk", thumbnail: textureAtlas.getTexture( "milk0000" ) },{ text: "Cheese", thumbnail: textureAtlas.getTexture( "cheese0000" ) },]},{header: "Bakery",children:[{ text: "Bread", thumbnail: textureAtlas.getTexture( "bread0000" ) },]},{header: "Produce",children:[{ text: "Bananas", thumbnail: textureAtlas.getTexture( "bananas0000" ) },{ text: "Lettuce", thumbnail: textureAtlas.getTexture( "lettuce0000" ) },{ text: "Onion", thumbnail: textureAtlas.getTexture( "onion0000" ) },]},]);list.itemRendererFactory = function():IGroupedListItemRenderer{var renderer:DefaultGroupedListItemRenderer = new DefaultGroupedListItemRenderer();renderer.labelField = "text";renderer.iconSourceField = "thumbnail";return renderer;};list.addEventListener( Event.CHANGE, list_changeHandler );this.addChild( list );}


效果:



更多说明参考:


0 0
原创粉丝点击