nativescript - 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 中是否有一种简单的方法可以做到这一点?
解决方案
推荐阅读
- javascript - 使用匹配每个子字符串的 RegExp 拆分字符串。整个字符串应该完全匹配
- python - 读取大型 JSON 文件时的垃圾值
- gitlab - 如何在 gitlab 中包含来自另一个仓库的文件夹
- node.js - 在接口 opencv4nodejs 中声明新方法
- javascript - 如何从这个 javascript 中减少代码行
- javascript - 如何等到生成pdf Javascript
- xml - xsl:for-each-group 在 xsl 2.0 中没有按预期工作
- java - Fragment 无法转换为 Fragment nextFragment
- javascript - 类型错误:firebaseApp.firestore 不是函数
- python - Python 错误语法:缺少 1 个必需的位置参数