首页 > 解决方案 > ListView 滑动删除

问题描述

有没有办法在 NativeScript 的 ListView 中实现这一点?
RadListView 内置了这种机制,但 ListView 对我的布局有更好的性能。
我一直在搜索文档,但似乎没有,所以我在本机元素中寻找一种方法:iOS 的 UITableView 和 Android 的 ListView-
对于 UITableView,我发现这篇博文表明:

在表格视图中启用滑动删除只需要一种方法:tableView(_:commit:forRowAt:)

那么如何将它翻译成 NativeScript 呢?
帖子中的快速代码是:

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        objects.remove(at: indexPath.row)
        tableView.deleteRows(at: [indexPath], with: .fade)
    } else if editingStyle == .insert {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
    }
}

此外,在 Android 的 ListView 中是否有一种简单的方法可以做到这一点?

标签: nativescript

解决方案


推荐阅读