Comments (2)
You can provide a custom item renderer by setting the itemRendererRecycler
property.
list.itemRendererRecycler = DisplayObjectRecycler.withClass(CustomItemRenderer);
If your custom item renderer implements the IDataRenderer
interface, the data
property will be set to an item from the ListView's data provider. You can interpret that item in any way that you'd like, inside an override of update()
.
However, DisplayObjectRecycler
makes it possible to skip implementing IDataRenderer
, if you'd prefer. You can optionally provide update
and reset
methods to that interpret the data.
Here's an example that creates a LayoutGroup with a Label and an AssetLoader:
var recycler = DisplayObjectRecycler.withFunction(() ->
{
var itemRenderer = new LayoutGroup();
var label = new Label();
label.name = "label";
itemRenderer.addChild(label);
var loader = new AssetLoader();
loader.name = "loader";
itemRenderer.addChild(loader);
return itemRenderer;
});
recycler.update = (itemRenderer, state) ->
{
var label = cast(itemRenderer.getChildByName("label"), Label);
var loader = cast(itemRenderer.getChildByName("loader"), AssetLoader);
label.text = state.text;
loader.source = state.data.url;
});
recycler.reset = (itemRenderer, state) ->
{
var label = cast(itemRenderer.getChildByName("label"), Label);
var loader = cast(itemRenderer.getChildByName("loader"), AssetLoader);
label.text = "";
loader.source = null;
});
list.itemRendererRecycler = recycler;
(Note: I haven't tried running that code, so it may need some minor tweaks to work properly)
I'm working on the documentation this month, and I'll try to go into more detail on item renderers. In the meantime, feel free to ask if anything is confusing.
from feathersui-openfl.
Thank You @joshtynjala!
from feathersui-openfl.
Related Issues (20)
- Haxe 4.3 no longer requires HashLink array resize() workaround
- FormItem.textPosition=LEFT and FormItem.horizontalAlign = JUSTIFY do not goes at same time HOT 1
- Port readjustLayout() to LayoutGroup and ScrollContainer from Starling version
- Copy/Paste in TextInput not works reliably HOT 4
- TextInput, TextArea: add missing factory for error callout
- BaseScrollContainer: ignore arrow keys, page up/down, and home/end when TextField of type INPUT has focus
- ListViewEvent.ITEM_TRIGGER return as `null` to handler method when used with GroupListView HOT 6
- TextInput content can copied when displayAsPassword=true HOT 2
- TextInput: Add new property to allow prompt to float above input text when focused
- ValidatingSprite using map instead of flags HOT 3
- Only the first row is rendered in `GridView` in a specific configuration.
- GridView: skin property for region to the right of headers and above scroll bar
- AssetLoader: property to display BitmapData and/or an arbitrary DisplayObject instead of loading with a string
- ToggleSwitch: optional on and off text
- Exception: Null Object Reference - Rectangle.hx HOT 5
- Exception: Null Object Reference - Clicking on Button HOT 9
- ItemRenderer: option to disable mouse/touch states
- ListView: scroll selected item fully into view if it is clicked/tapped
- Alert: optional close button in header
- New Component: Window/dialog: Similar to Alert, but allows completely custom content
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feathersui-openfl.