Rendering fragments in Adapters
Fragments in Adapters This is a black magic that I met recently, There is an Adapter pattern in Android, which bonds the data and View together, but what if the data part is a bunch of fragments. Can we render fragments in Adapters? After doing some research and experiments, the answer is: Fragments can be rendered in Adapters in some conditions. ListView .vs. RecyclerView When comes to Adapter pattern in Android, there are two kinds of Adapters, AdapterView, and RecyclerView, while the AdapterView is an abstract class, its most famous representative is the ListView. What’s the difference between ListView and RecyclerView? ListView is the child of AdapterView, while RecyclerView is inherited from ViewGroup. I think that’s the biggest inherent difference. RecyclerView is also considered as the replacement for the ListView, it is invited in lollipop age, and with some benefits inside: ViewHolder pattern inside; decoupling the item layout manager; isolated ite...