使用 SlidingListTile 时阻止垂直滚动

Block vertical scroll while using SlidingListTile

我想使用 SlidingListTile,但遇到了一些问题。 我认为当我们使用水平滑动时垂直滚动应该被锁定,因为在 phone.

上很难完成滑动。

有人遇到过这样的情况吗?

提前致谢,

这是我的部分代码:

    slidingTile.swipedLeftProperty().addListener((obs, ov, nv) -> {
        if (nv && edit != null) {
            edit.accept(currentItem);
        }
        slidingTile.resetTilePosition();
    });
    slidingTile.swipedRightProperty().addListener((obs, ov, nv) -> {
        if (nv && edit != null) {
            edit.accept(currentItem);
        }
        slidingTile.resetTilePosition();
    });

确实,评论2.0有错误sample

CommentsPresenterListView 定义自定义 ListCell,并从单个 BooleanProperty 到每个单元格创建 binding列表视图:

commentsList.setCellFactory(cell -> { 
        final CommentListCell commentListCell = new CommentListCell(
                service,...);

        // notify view that cell is sliding
        sliding.bind(commentListCell.slidingProperty());

        return commentListCell; 
    });

显然,每个单元格的滑动属性可能会随着时间的推移而变化,但只会以最后一组为准,所以它不会反映任何一个属性的变化其余单元格。

修复很简单:不要使用绑定,而是为每个单元格设置一个监听器,它将在该单元格滑动时设置值:

commentsList.setCellFactory(cell -> { 
        final CommentListCell commentListCell = new CommentListCell(
                service,...);

        // notify view that cell is sliding
        commentListCell.slidingProperty().addListener((obs, ov, nv) -> 
            sliding.set(nv));

        return commentListCell; 
    });

我已经提交了 issue