【发布时间】:2020-08-22 00:23:04
【问题描述】:
我正在尝试使用 Epoxy Library 将 RecyclerView 添加到我的应用中
我需要在EpoxyModelWithHolder 的bind 方法中获取项目的位置,但我不知道该怎么做。
我找不到任何函数来获取持有人/物品的位置。
【问题讨论】:
标签: android android-studio kotlin android-recyclerview epoxy
我正在尝试使用 Epoxy Library 将 RecyclerView 添加到我的应用中
我需要在EpoxyModelWithHolder 的bind 方法中获取项目的位置,但我不知道该怎么做。
我找不到任何函数来获取持有人/物品的位置。
【问题讨论】:
标签: android android-studio kotlin android-recyclerview epoxy
解决方案是在您的模型中设置一个 Integer EpoxyAttribute,并在您的控制器中将其设置为 buildItemModel 方法中的 id。
在您的模型中:
@EpoxyAttribute
Integer position;
在控制器中:
public EpoxyModel<?> buildItemModel(int i, yourmodel) {
return model()_.id(i).position(i);
}
【讨论】: