74 lines
2.2 KiB
Java
74 lines
2.2 KiB
Java
|
|
package com.skipping.activity.detail;
|
|||
|
|
|
|||
|
|
import android.content.Context;
|
|||
|
|
import android.view.LayoutInflater;
|
|||
|
|
import android.view.View;
|
|||
|
|
import android.view.ViewGroup;
|
|||
|
|
import android.widget.TextView;
|
|||
|
|
|
|||
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|||
|
|
|
|||
|
|
import com.skipping.R;
|
|||
|
|
import com.skipping.net.DetailActivityBean;
|
|||
|
|
import com.skipping.net.GradleBean;
|
|||
|
|
|
|||
|
|
import java.util.ArrayList;
|
|||
|
|
import java.util.List;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @author Ming
|
|||
|
|
* 3/18/22
|
|||
|
|
*/
|
|||
|
|
public class DetailAdapter extends RecyclerView.Adapter<DetailAdapter.RecyclerHolder> {
|
|||
|
|
private OnClick onClick;
|
|||
|
|
private Context mContext;
|
|||
|
|
private List<DetailActivityBean.CandidatesBean> list = new ArrayList<>();
|
|||
|
|
|
|||
|
|
public DetailAdapter(RecyclerView recyclerView) {
|
|||
|
|
this.mContext = recyclerView.getContext();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void setData(List<DetailActivityBean.CandidatesBean> list) {
|
|||
|
|
this.list = list;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public DetailAdapter.RecyclerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|||
|
|
View view = LayoutInflater.from(mContext).inflate(R.layout.detail_item, parent, false);
|
|||
|
|
return new DetailAdapter.RecyclerHolder(view);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public void onBindViewHolder(DetailAdapter.RecyclerHolder holder, int position) {
|
|||
|
|
holder.name.setText("学生名称:" + list.get(position).getName());
|
|||
|
|
holder.id.setText("ID:" + list.get(position).getPersonID());
|
|||
|
|
holder.studentid.setText("学生ID:" + list.get(position).getStudentID());
|
|||
|
|
holder.score.setText("分数:" + list.get(position).getScore());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public int getItemCount() {
|
|||
|
|
return list.size();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class RecyclerHolder extends RecyclerView.ViewHolder {
|
|||
|
|
TextView name, id, studentid, score;
|
|||
|
|
|
|||
|
|
private RecyclerHolder(View itemView) {
|
|||
|
|
super(itemView);
|
|||
|
|
name = itemView.findViewById(R.id.name);
|
|||
|
|
id = itemView.findViewById(R.id.id);
|
|||
|
|
studentid = itemView.findViewById(R.id.studentid);
|
|||
|
|
score = itemView.findViewById(R.id.score);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void setOnClickListener(OnClick onClick) {
|
|||
|
|
this.onClick = onClick;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public interface OnClick {
|
|||
|
|
void click(String id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|