在 Titanium mobile 中删除 TableViewRow
我有一个 TableView,但由于各种原因不想使用内置的滑动删除功能。因此,我在该行中有一个按钮可以删除包含的行。我该怎么做呢? TableView 对象有一个deleteRow() 函数,但它需要删除行的索引,据我所知,没有办法从TableViewRow 对象获取该索引。
I have a TableView, but don't want to use the builtin swipe-to-delete functionality for various reasons. So, I have a button in that row that should delete the containing row. How would I do that? The TableView object has a deleteRow() function, but it requires the index of the row to be deleted, and as far as I know, there isn't a way to get that from a TableViewRow object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在创建按钮时将行索引设置为按钮的属性
,您可以将事件侦听器放在整行上,检测源对象何时是按钮,然后您将获得索引和按钮单击事件删除。
有多种方法,一些代码可以帮助我指导您找到最佳解决方案
you could set the row index as a property of the button when you create the button
you could put the event listener on the whole row, detect when the source object is the button and then you would have the index and the button click event for the delete.
there are multiple approaches, some code would help me to direct you to the best solution