0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Epoxyで最初のアイテムだけViewが違うRecyclerviewを実装したい

Posted at

初めに

今回はEpoxyライブラリで最初のアイテムだけViewが違うRecyclerViewを実装していきたいと思います。

本文

override fun addModels(models: List<EpoxyModel<*>>) {
    val item = ExcampleBindingModel_().apply { id("header") }

    super.addModels(
        buildList {
            add(item)
            addAll(models)
        }
    )
}

addModelsbuildItemModelで作ったEpoxyModelのリストをViewに当てはめてくれる部分なのでその段階でヘッダーに設定したいViewを最初にaddするようにしてあげればいいだけです。

最後に

ヘッダーだけViewを変えたい等で役立つかと思います。
何かの実装の参考になれば幸いです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?