我尝试在RecyclerView中实施Admob广告。我尝试了很多例子,但没有问题。 我想在我的RecyclerView的8个项目之间插入一个广告
public class StarRVAdapter extends RecyclerView.Adapter<StarRVViewHolder>{
private Context c;
private ArrayList<Questions> questionEntries;
Questions qe;
StarRVViewHolder holderClass;
String answerCount=null,likes;
public StarRVAdapter(Context c, ArrayList<Questions> questionEntries,Questions qe) {
this.c = c;
this.qe = qe;
this.questionEntries = questionEntries;
}
@Override
public StarRVViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v= LayoutInflater.from(c).inflate(R.layout.actu_list_item,parent,false);
return new StarRVViewHolder(v,c);
}
@Override
public void onBindViewHolder(final StarRVViewHolder holder, int position) {
qe = (Questions)this.getItem(position);
holder.setDate(qe.getQuestion_date());
holder.setContent(qe.getQuestion_content());
holder.setImg(qe.getImgUrl());
holder.setTitle(qe.getQuestion_title());
holder.setAsker(qe.getQuestion_username());
holder.setNumberOfAnswer(getAnswers());
holder.setNumberOfLikes(getLikeksCount());
Toast.makeText(c,qe.question_title,Toast.LENGTH_LONG).show();
}
@Override
public int getItemCount() {
return questionEntries.size();
}
public Object getItem(int position) {
return questionEntries.get(position);
}
} 这是我的Asdapter课程。感谢