Why RecyclerView uses ViewHolder as an InnerClass for Adapters?

Asked 2 years ago, Updated 2 years ago, 22 views

That's why it's called. Is that English or Korean?) I made a separate holder package and always worked separately with the adapter and holder Recently, I saw a comment that it is better to make the holder into an adapter's inner class, so I'm asking you a question.

android

2022-09-21 21:17

1 Answers

Usually, the adapter that uses the holder exclusively uses it, so I think it's often used as an internal class (in the sense of limiting the scope). However, separating the holder into an external class does not mean that it is an incorrect code. If the holder is reused in other classes, then it's a good choice to take it apart. In fact, this part is more of a matter of how to design the code, so I think it would be better to choose a method that fits the situation at that time.


2022-09-21 21:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.