多条目

``
多条目`
@NonNull
@Override
public XRecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view;
if (iBANNER_TYPR){
view= LayoutInflater.from(context).inflate(R.layout.xbanner,viewGroup,false);
xBannerHolder = new XBannerHolder(view);
return xBannerHolder;
}else if (i
RXXP_TYPR){
view= LayoutInflater.from(context).inflate(R.layout.rxxp,viewGroup,false);
rxxpHolder = new RxxpHolder(view);
return rxxpHolder;
}else if (iPZSH_TYPR){
view= LayoutInflater.from(context).inflate(R.layout.pzsh,viewGroup,false);
pzshHolder = new PzshHolder(view);
return pzshHolder;
}else if (i
MLSS_TYPR){
view= LayoutInflater.from(context).inflate(R.layout.mlss,viewGroup,false);
mlssHolder = new MlssHolder(view);
return mlssHolder;
}
return null;
}

@Override
public void onBindViewHolder(@NonNull XRecyclerView.ViewHolder viewHolder, int i) {

if (viewHolder instanceof XBannerHolder){
XBannerHolder xBannerHolder= (XBannerHolder) viewHolder;
result = xBannerBean.getResult();
xBannerHolder.shou_banner.setData(result,null);
xBannerHolder.shou_banner.setmAdapter(new XBanner.XBannerAdapter() {
@Override
public void loadBanner(XBanner banner, View view, int position) {
Glide.with(context).load(result.get(position).getImageUrl()).into((ImageView) view);
}
});
xBannerHolder.shou_banner.setPageChangeDuration(1000);

}else if (viewHolder instanceof RxxpHolder){
RxxpHolder rxxpHolder = (RxxpHolder) viewHolder;
rxxpHolder.rxxp_text.setText(shouBean.getResult().getRxxp().getName());
LinearLayoutManager manager=new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL,false);
rxxpHolder.rxxp_recy.setLayoutManager(manager);
commodityList = shouBean.getResult().getRxxp().getCommodityList();
rxxpAdapter = new RxxpAdapter(commodityList,context);
rxxpHolder.rxxp_recy.setAdapter(rxxpAdapter);
rxxpAdapter.setCallBackAA(new RxxpAdapter.CallBackAA() {
@Override
public void dianji(String id) {
Toast.makeText(context,id,Toast.LENGTH_LONG).show();
Log.i(“aaa”,id);
}
});

}else if (viewHolder instanceof PzshHolder){
PzshHolder pzshHolder= (PzshHolder) viewHolder;
pzshHolder.pzsh_text.setText(shouBean.getResult().getPzsh().getName());
LinearLayoutManager manager=new LinearLayoutManager(context);
pzshHolder.pzsh_recy.setLayoutManager(manager);
commodityList1 = shouBean.getResult().getPzsh().getCommodityList();
pzshHolder.pzsh_recy.setAdapter(new PzshAdapter(commodityList1,context));
}else if (viewHolder instanceof MlssHolder){
MlssHolder mlssHolder= (MlssHolder) viewHolder;
mlssHolder.mlss_text.setText(shouBean.getResult().getMlss().getName());
LinearLayoutManager manager=new GridLayoutManager(context,2);
mlssHolder.mlss_recy.setLayoutManager(manager);
commodityList2 = shouBean.getResult().getMlss().getCommodityList();
mlssHolder.mlss_recy.setAdapter(new MlssAdapter(commodityList2,context));

}
}

@Override
public int getItemCount() {
    return 4;
}

@Override
public int getItemViewType(int position) {

    if (position==0){
    return BANNER_TYPR;
    }else if (position==1){
        return RXXP_TYPR;
    }else if (position==2){
        return PZSH_TYPR;
    }else if (position==3){
        return MLSS_TYPR;
    }
    return super.getItemViewType(position);

}

//xbannerholder
public class XBannerHolder extends RecyclerView.ViewHolder {

    private final XBanner shou_banner;

    public XBannerHolder(@NonNull View itemView) {
        super(itemView);
        shou_banner = itemView.findViewById(R.id.shou_banner);
    }
}
//rxxpholder
public class RxxpHolder extends RecyclerView.ViewHolder {

    private final TextView rxxp_text;
    private final RecyclerView rxxp_recy;
    public RxxpHolder(@NonNull View itemView) {
        super(itemView);
        rxxp_text = itemView.findViewById(R.id.rxxp_text);
        rxxp_recy = itemView.findViewById(R.id.rxxp_recy);
    }
}
//pzshholder
public class PzshHolder extends RecyclerView.ViewHolder {

    private final TextView pzsh_text;
    private final RecyclerView pzsh_recy;
    public PzshHolder(@NonNull View itemView) {
        super(itemView);
        pzsh_text = itemView.findViewById(R.id.pzsh_text);
        pzsh_recy = itemView.findViewById(R.id.pzsh_recy);
    }
}
//mlssholder
public class MlssHolder extends RecyclerView.ViewHolder {

    private final TextView mlss_text;
    private final RecyclerView mlss_recy;
    public MlssHolder(@NonNull View itemView) {
        super(itemView);
        mlss_text = itemView.findViewById(R.id.mlss_text);
        mlss_recy = itemView.findViewById(R.id. mlss_recy);
    }
}

你可能感兴趣的:(多条目)