0

通过{N}教程我想实现这一点:

预期的

但是我无法显示这个删除按钮。

它在其他地方很好地显示的图像没有问题,我也尝试放置一个标签,但结果相同。

Rad Listview 组件:

<RadListView row="1" [items]="groceryList"
  swipeActions="true" (itemSwipeProgressStarted)="onSwipeCellStarted($event)">

    <ng-template let-item="item">
      <Label [text]="item.name" class="p-15"></Label>
    </ng-template>

    <GridLayout *tkListItemSwipeTemplate columns="*, auto">
      <StackLayout id="delete-view" col="1" (tap)="delete($event)" class="delete-view">
        <Image src="~/images/delete.png" ></Image>
      </StackLayout>
    </GridLayout>

  </RadListView>

CSS:

.delete-view {
    background-color: #CB1D00;
    padding: 20;
}
.delete-view Image {
    color: white;
    height: 25;
}

TS

onSwipeCellStarted(args: ListViewEventData) {
    var swipeLimits = args.data.swipeLimits;
    var swipeView = args.object;
    var rightItem = swipeView.getViewById<View>("delete-view");
    swipeLimits.right = rightItem.getMeasuredWidth();
    swipeLimits.left = 0;
    swipeLimits.threshold = rightItem.getMeasuredWidth() / 2;
  }

  delete(args: ListViewEventData) {
    let grocery = <Grocery>args.object.bindingContext;
    this.groceryService.delete(grocery.id)
      .subscribe(() => {
        let index = this.groceryList.indexOf(grocery);
        this.groceryList.splice(index, 1);
      });
  }

删除功能效果很好,但我在刷卡时得到的只是:

结果

我在这里做错了什么?

4

1 回答 1

0

本月早些时候,我花了几天时间处理 RadListView 的类似问题,尤其是在 iOS 上。这似乎违背了逻辑。我最终使用了一个负填充来到达我可以看到我的标签和图标的地方。如果这没有帮助,请尝试从您的 CSS 中删除 height::

于 2020-08-30T14:10:55.087 回答