0

我正在尝试使用 Epoxy Library 将 RecyclerView 添加到我的应用程序中,我需要在bind方法中获取项目的位置,EpoxyModelWithHolder但我不知道该怎么做。

我找不到任何功能来获取持有人/物品的位置。

4

1 回答 1

1

解决方案是在您的模型中设置一个 Integer EpoxyAttribute,并在您的控制器中将其设置为来自 buildItemModel 方法的 id。

在您的模型中:

@EpoxyAttribute
Integer position;

在控制器中:

public EpoxyModel<?> buildItemModel(int i, yourmodel) {

return model()_.id(i).position(i);

}
于 2020-10-18T16:53:29.100 回答