我在标签布局中有这个水平回收视图。
我确信的事情: 1.该列表不为空并正确传递。 2.调用适配器构造函数方法。 3.片段被调用。
适配器代码:
public class ProjectAdapter extends RecyclerView.Adapter<ProjectAdapter.ProjectViewHolder> {
ArrayList<ProjectModel> project;
public ProjectAdapter(ArrayList<ProjectModel> project) {
this.project = project;
}
public static class ProjectViewHolder extends RecyclerView.ViewHolder {
TextView title, desc;
public ProjectViewHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.proj_element_title);
desc = (TextView) itemView.findViewById(R.id.proj_element_desc);
}
}
@Override
public ProjectViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.projects_element, parent, false);
return new ProjectViewHolder(view);
}
@Override
public void onBindViewHolder(ProjectViewHolder holder, int position) {
//holder.imageView.setImageResource(projectModel.getImg_res());
holder.title.setText(project.get(position).getTitle());
holder.desc.setText(project.get(position).getDesc());
}
@Override
public int getItemCount() {
return project.size();
}
}
我在
添加了调试点holder.title.setText(project.get(position).getTitle());
holder.desc.setText(project.get(position).getDesc());
return project.size();
但他们从未被召唤过。
可能是什么问题?