先看adapter类
public class ControlPersonAdapter extends RecyclerView.Adapter<ControlPersonAdapter.ViewHolder> {
private List<ControlPerson> controlPerson;
private Context context;
static class ViewHolder extends RecyclerView.ViewHolder{
TextView name;
TextView number;
TextView commandTitle;
TextView command;
TextView startTime;
TextView endTime;
Button edit,delete;
public ViewHolder(View view) {
super(view);
name = (TextView)view.findViewById(R.id.name);
number = (TextView)view.findViewById(R.id.number);
commandTitle = (TextView)view.findViewById(R.id.command_title);
command = (TextView)view.findViewById(R.id.command);
startTime = (TextView)view.findViewById(R.id.start_time);
endTime = (TextView)view.findViewById(R.id.end_time);
edit = (Button)view.findViewById(R.id.edit);
delete = (Button)view.findViewById(R.id.delete);
}
}
public ControlPersonAdapter(List<ControlPerson> controlPerson){
this.controlPerson = controlPerson;
}
// public void setList(List<ControlPerson> controlPerson){
// this.controlPerson = controlPerson;
// }
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_control,parent,false);
context = parent.getContext();
ViewHolder holder = new ViewHolder(view);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override