如何在我的项目渲染器中显示项目索引。项目渲染器的所有者是TileList。 http://www.swsd.k12.pa.us/baresvle/mathmaterials/numbers/number_grid.jpg
答案 0 :(得分:4)
我最好的猜测是在itemRenderer中尝试这样的事情:
var index: int = ((listData.owner as TileList).dataProvider as ListCollectionView).getItemIndex())
答案 1 :(得分:0)
private var handleDataChangedEnabled:Boolean = false;
private var myOwner : TileList;
override public function set data(value:Object):void
{
super.data = value;
myOwner = owner as TileList;
if (!handleDataChangedEnabled) {
addEventListener("dataChange", handleDataChanged);
}
}
public function handleDataChanged(event:Event):void {
this.gridValue.text = String((myOwner.dataProvider as ListCollectionView).getItemIndex(data));
}
将此代码添加到tileList项目渲染器,添加Label(id gridValue)以显示网格编号。谢谢!
答案 2 :(得分:0)
ItemRenderer中有一个名为itemIndex的属性。就这么简单!