import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CheckedTextView;
import com.bawei.moni.R;
import com.bawei.moni.bean.ThreeBean;
import com.bawei.moni.bean.Two;
import java.util.List;
/**
-
@Author:苏羡c
-
@E-mail:
-
@Date:2019/4/4 9:48
-
@Description:描述信息
*/
public class FirstAdapter extends RecyclerView.Adapter<FirstAdapter.ViewHolder> {
Context context;
List list;public FirstAdapter(Context context, List list) {
this.context = context;
this.list = list;
}@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(context).inflate(R.layout.item_shop, viewGroup, false);
ViewHolder viewHolder = new ViewHolder(view);
return viewHolder;
}@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
Two two = list.get(i);
viewHolder.bind(two);
}@Override
public int getItemCount() {
return list.size();
}public class ViewHolder extends RecyclerView.ViewHolder {
private final CheckBox shop_check; private final CheckedTextView shop_name; private final RecyclerView shop_view; private TwoAdapter twoAdapter; public ViewHolder(@NonNull View itemView) { super(itemView); shop_check = itemView.findViewById(R.id.shop_check); shop_name = itemView.findViewById(R.id.shop_name); shop_view = itemView.findViewById(R.id.shop_view); } public void bind(Two two){ String sellerName = two.getSellerName(); shop_name.setText(sellerName); shop_check.setChecked(two.isChecked()); List<ThreeBean> list = two.getList(); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); shop_view.setLayoutManager(linearLayoutManager); twoAdapter = new TwoAdapter(context,list); shop_view.setAdapter(twoAdapter); }
}
}