I do have a list of data, which are male and female types. I already populated data in same space item divider all the male and female data. But what i want here, I want populated male data like 1dp and after male finished, need big space here like 10dp and female should also populated just like male 1dp item divider.
Is it possible in one recycelrview or i have to create two recyclerview.
I tried to create two recyclerview which is working fine but need under 1 recyclerview.
Since you already have two types, I'm guessing you already know how to distinguish male and female views in the RecyclerView.
The classic approach would be to have a third type, which would be the "divider". This can be implemented by either using ViewTypes in the Recycler or by having one generic layout for the items that will transform onBinding from male, to female or to divider depending on the cell's position
.
The way I've been using and I highly recommend is to use a ConcatAdapter! With this incredible component you can combine many different adapters into one. In this case, you'd need for example a MaleAdapter, a FemaleAdapter, and a DividerAdapter (which will have only one item, a SpaceView of 10dp height).
ConcatAdapter might seem like overkill for just a divider, but the DividerAdapter will be re-usable and the ConcatAdapter is extremely flexible. Just imagine the scenario where you'll later need to add a completely different view, like a DogAdapter, all you'll have to do is create the new adapter and add it to the ConcatAdapter with just one more DividerAdapter before it. Clean and fast.