0

我有一个 ArrayCollection,我希望能够将项目向上或向下冒泡一个位置。做这个的最好方式是什么?

4

2 回答 2

6
var ac:ArrayCollection = new ArrayCollection(yourArraySource);
ac.removeItemAt(n); // where n > 0 and n < ac.length
ac.addItemAt( item, n-1); // where n>0 ... you should test for that

等等

于 2010-03-23T00:25:11.110 回答
1

将 Robusto 的两个函数调用组合成一行:)

ac.addItemAt(ac.removeItemAt(n), n-1);

ArrayList 上的remove...函数返回要删除的项目,因此您可以轻松地在集合中重新定位它。

于 2010-03-23T01:30:12.550 回答