1

I'm working with a recyclerView in my app that has three different layouts for it's rows.

I change the visibility of the different views in the layout for each row depending on the the type of data. For example, if it's a text post I change the visibility of the imageView to invisible and if it's an image post I change the visibility of the textView.

Is this a bad practice? Will this be too much overhead for the app?

Nissim R
  • 542
  • 11
  • 29
moe_nyc
  • 307
  • 1
  • 4
  • 18

2 Answers2

1

It's not the best approach. See this: How to create RecyclerView with multiple view type?

There are also libraries in case you need more complex behavior while keeping a clean structure. For example, see Groupie.

Xavier Rubio Jansana
  • 6,388
  • 1
  • 27
  • 50
1

Please check this answer.

Main idea - you should implement getItemViewType of appropriate adapter and create layout accordingly with type returned by getItemViewType