I have used sectioned recycler view library called "IntruderShanky/SectionedRecyclerView".
The link for sectioned library Sections recycler view
Using this library i have successfully added sections with child items, but the problem is i have to add ads after each 10 items.
Suppose i have 5 sections with each having 10 childs i.e
void section_item_adder()
{
for (int j=0;j<5; j++) {
for (int i = 0; i < 10; i++) {
childList.add(new Child(Section_filepath, Section_filename, false, FileSize_Check));
}
sectionHeaders.add(new SectionHeader(childList, "Group " + section_counter + "", section_counter + 1));
}
}
for child item i am passing Child class objects as list, but what should i do with native ads to be passed as child in sections.
public static final int ITEM_PER_AD = 10;
void SetAdsInAdapter()
{
for(int i = 0; i < sectionHeaders.size();i+= ITEM_PER_AD)
{
final AdView adView = new AdView (MainActivity.this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(NATIVE_AD_ID);
// sectionHeaders.add(new SectionHeader(childList, "" ,section_counter+1));
// adapterRecycler.a
sectionHeaders.add(new SectionHeader(section_counter+1));
}
}