【问题标题】:How to get Item Position in EpoxyModelWithHolder?如何在 EpoxyModelWithHolder 中获取项目位置?
【发布时间】:2020-08-22 00:23:04
【问题描述】:

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

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

【问题讨论】:

    标签: android android-studio kotlin android-recyclerview epoxy


    【解决方案1】:

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

    在您的模型中:

    @EpoxyAttribute
    Integer position;
    

    在控制器中:

    public EpoxyModel<?> buildItemModel(int i, yourmodel) {
    
    return model()_.id(i).position(i);
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-26
      • 1970-01-01
      • 2013-09-28
      • 1970-01-01
      • 1970-01-01
      • 2022-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多