Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在RecyclerView上显示间隙广告,_Java_Android_Admob_Interstitial - Fatal编程技术网

Java 如何在RecyclerView上显示间隙广告,

Java 如何在RecyclerView上显示间隙广告,,java,android,admob,interstitial,Java,Android,Admob,Interstitial,当用户在“转到下一个活动”之前单击列表项时,需要显示间隙广告;当广告关闭时,用户应转到下一个活动;如果广告未能加载,用户还应转到下一个活动。 下面是我的自定义适配器代码。有人能告诉我如何在其中实现admob中间广告吗 这是我的customadapter public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.CustomHolder> { Context context; publ

当用户在“转到下一个活动”之前单击列表项时,需要显示间隙广告;当广告关闭时,用户应转到下一个活动;如果广告未能加载,用户还应转到下一个活动。 下面是我的自定义适配器代码。有人能告诉我如何在其中实现admob中间广告吗

这是我的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);
        }
    }

}
公共类CustomAdapter扩展了RecyclerView.Adapter{ 语境; 公共CustomAdapter(上下文上下文,字符串[]标题,字符串[]HTML文件){ this.context=上下文; this.title=标题; this.htmlFile=htmlFile; } 字符串[]标题; 字符串[]htmlFile; @非空 @凌驾 public CustomHolder onCreateViewHolder(@NonNull ViewGroup parent,int viewType){ LayoutInflater LayoutInflater=LayoutInflater.from(上下文); 视图=布局更平坦。充气(R.布局。项目列表,父项,false); 返回新的客户持有人(视图); } @凌驾 public void onBindViewHolder(@NonNull CustomHolder,int位置){ 最后一个字符串htmlfile=htmlfile[位置]; holder.textView.setText(标题[位置]); holder.linearLayout.setOnClickListener(新视图.OnClickListener(){ @凌驾 公共void onClick(视图v){ 意向意向=新意向(上下文,StudyActivity.class); intent.putExtra(“文件”,htmlfile); 背景。开始触觉(意图); ((CategoryActivity)上下文).finish(); } }); } @凌驾 public int getItemCount(){ 返回title.length; } 公共类CustomHolder扩展了RecyclerView.ViewHolder{ 线性布局线性布局; 文本视图文本视图; 公共CustomHolder(@NonNull View itemView){ 超级(项目视图); linearLayout=(linearLayout)itemView.findViewById(R.id.linear); textView=(textView)itemView.findViewById(R.id.title); } } }
可能重复-这是否回答了您的问题@不,这不是答案。这对我不管用。任何人都可以帮我吗??我非常需要它。可能是重复的-这能回答你的问题吗@不,这不是答案。这对我不管用。任何人都可以帮我吗??我非常需要它。