【问题标题】:Is there a way to programmatically perform a swipe action on a radlistview item?有没有办法以编程方式对 radlistview 项目执行滑动操作?
【发布时间】:2020-08-08 18:04:15
【问题描述】:

我正在使用 nativescript 和 angular,并且我有一个 RadListView 和点击执行滑动操作。向左滑动显示删除按钮,向右滑动显示“选项”按钮。

加载项目后,我想以编程方式向右滑动第一个项目。我知道我可以使用 getViewItemAt(O) 获得第一项的视图,但我不知道这是否可行或如何对其应用程序化滑动手势

【问题讨论】:

标签: android nativescript swipe radlistview


【解决方案1】:

更新

如果其他人正在寻找这个,可以通过简单地为项目视图设置动画来实现

... items loaded ... then 
{
    let item = this.radList.listView.getItemAtIndex(0);
    let view = this.radList.listView.getViewForItem(item);
    setTimeout(()=> {
        //animate on x axis - will show the swipe action at the right 
        view.animate({
            translate: { x: 80, y: 0},
            duration: 50,
            curve: AnimationCurve.spring
        });
        //animate back to hide it
        setTimeout(()=> {
            view.animate({
                translate: { x: 0, y: 0},
                duration: 50,
                curve: AnimationCurve.spring
            });
        }, 1000);

    }, 2000);  
}
...

【讨论】:

  • 我可以让它在 Android 上运行。在 iOS 上,项目移动是动画的,但滑动动作是不可见的。如果这对你来说在两个平台上都有效,你能分享你使用的样式吗?
猜你喜欢
  • 2021-09-09
  • 1970-01-01
  • 2016-09-17
  • 2021-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-10
  • 1970-01-01
相关资源
最近更新 更多