I am working on an application where I need to show the recyclerView inside recyclerView. Now, recyclerView inside recyclerView is conditional based. If we have data there for the innerRecyclerView then only we need to show it else no need to show it.
Here I am facing the issue is as follows:
On the 1st position, I have taken the condition for the showing/hiding inner recyclerView,
Then in the rest condition main recyclerView is loading data properly.
Now on the 0th position of recyclerView if I am showing the innerRecyclerView there them the 1st position of the main outer recyclerView will load the data for the 1st position of ArrayList, whereas it should start from the 0th position of ArrayList. So here the 0th data from the ArrayList was skipped and load the data from the 1st position of recyclerView.
Is there any way to load the 0th data from the ArrayList in the 1st position of recyclerView?
The logic for the code is like:
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, final int position) {
if (viewHolder instanceof HomeViewHolder) {
if(position == 0} {
// Data for the innerRecyclerView is available:
if(recentList.size() > 0 ) {
// Show innerRecyclerView..
// Load data for the inner recyclerview.
} else {
// Hide the inner recyclerView..
}
} else {
// Load the data for the outer recyclerView with the rest of the position..
// If we are showing the innerRecyclerView then it will start only loading the data from the position 1 from the array list..
}
}
}
Please consider the design for the screen as:
Please let me know if you have any queries on this question.