AddChildAt() 在特定索引位置添加项目
我有一个文本框,我将其用作邮件地址输入字段,用户可以在其中输入多个地址,与 hotmail 中的有点相同。每个地址都呈现为一个可点击的按钮。因此,在双击特定地址时,我希望该项目可编辑。当用户点击输入编辑地址后,该项目将被添加到邮件添加列表中。
我使用下面的代码添加它:
flowBox.addChildAt( myItem, myindex);
但是 addChildAt 似乎将该项目添加为列表中的最后一个项目。但我希望它将项目添加到原来的位置。假设该项目位于邮件列表中的位置 2,编辑并点击 Enter 后,它应该添加到位置 2 本身,而不是添加到列表的末尾。
你能告诉我是否有什么办法可以做到这一点?
谢谢
I have a textBox and I am using it as a mail address input field where the user can type in several addresses, a bit same as in hotmail. Each address is rendered into a clickable button. Thus upon double-clicking on a specific address I want the item to be editable. After having edited the address when the user taps enter, the item is added to the list of mail adds.
I am adding it using the code below:
flowBox.addChildAt( myItem, myindex);
However addChildAt seems to add the item as the last item in the list. But I want it to add the item the position where it was originally. Say the item was at position 2 in the mail list, after editing adn tapping enter, it should add at position 2 itself and not at the end of the list.
Can you please tell me if there is any way for doing this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
addElementAt()
代替。更多详细信息请参见此处。Try to use
addElementAt()
instead. More details are here.你可以按照Constantiner的建议去做,也许是addChildAt(index)。
另一种方法是隐藏子项并通过可见属性显示子项,而不是删除和添加
You can do what Constantiner has suggested, perhaps it's addChildAt(index).
The other way of doing is just hide the child and show the child instead by visible property instead of removing and adding