i want to display native ads in between adpaterlist in recycler view .The native ad is not showing but the adapterlist aswell as progress bar works fine
public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup viewGroup, int i) {
if (i == 1) {
return new MyViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_template_adapter_list, viewGroup, false));//show list of items
}
if (i != 2) {
return new LoadingHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.progress_view, viewGroup, false));//shows progressbar
}
return new AdHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.ad_view, viewGroup, false));//this statement never called for loading native ad
}
public Object getItem(int i) {
return this.posterDatas.get(i);
}
public int getItemCount() {
ArrayList<Object> arrayList = this.posterDatas;
if (arrayList == null) {
return 0;
}
return arrayList.size();
}
@Override
public int getItemViewType(int i) {
if (this.isLoaderVisible) {
if (i == this.posterDatas.size() - 1) {
return 0;
}
if (this.posterDatas.get(i) instanceof String) {
return 2;
}
return 1;
} else if (this.posterDatas.get(i) instanceof String) {
return 2;
} else {
return 1;
}
}
return new AdHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.ad_view, viewGroup, false));
this line is never executed thats why ad is not loading because i==2 condition never occurrs
i want to show both native ad and adapterlist items in parallel. Native ad should show between adapterlist items as given in the image.Because the value of i==2 doesnt occur am not able to execute the return statement for adloader
make sure u have followed the steps in this documentation : https://support.google.com/admob/answer/7187428?hl=en
hope this helps ... good luck ❤️.