How to show interstitial ads on RecyclerView,

Viewed 949

When user click an list Item before the go to next activity need to show interstitial ads, when ads closed they should go to next activity or if ads failed to load they should also go to next activity. Below is my custom adapter code. can anyone please let me know how can i implement admob interstitial ads in it?

Here is my customadapter

public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.CustomHolder> {

    Context context;

    public CustomAdapter(Context context, String[] title, String[] htmlfile) {
        this.context = context;
        this.title = title;
        this.htmlFile = htmlfile;
    }

    String[] title;
    String[] htmlFile;


    @NonNull
    @Override
    public CustomHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View view = layoutInflater.inflate(R.layout.item_list,parent,false);




        return new CustomHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull CustomHolder holder, int position) {

        final String htmlfile = htmlFile[position];

        holder.textView.setText(title[position]);
        holder.linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context,StudyActivity.class);
                intent.putExtra("file",htmlfile);
                context.startActivity(intent);
                ((CategoryActivity)context).finish();
            }
        });

    }

    @Override
    public int getItemCount() {
        return title.length;
    }

    public class CustomHolder extends RecyclerView.ViewHolder {

        LinearLayout linearLayout;
        TextView textView;


        public CustomHolder(@NonNull View itemView) {
            super(itemView);
            linearLayout = (LinearLayout) itemView.findViewById(R.id.linear);
            textView = (TextView) itemView.findViewById(R.id.title);
        }
    }

}
0 Answers
Related