RecycleView,其中Arraylist的每一项都包含两个arraylist

时间:2017-08-02 05:23:52

标签: android dynamic view android-recyclerview

在RecycleView中有一个Arraylist,每个项目包含两个不同大小的arraylists,实际上我想显示购物车项目,但我的问题是每个订单有两种类型的订单,一种是包类型,另一种是盒子类型,我想要显示数据,因为我已根据发票编号给出订单和数据显示,并且每个项目都有不同类型的产品数量,我已正确解析数据但在给出特定布局时出现问题。我的布局可以区分具有多个的每个特定订单data.Here我的适配器类。

public class OrderAdapter extends RecyclerView.Adapter<OrderAdapter.ItemRowHolder> {

ArrayList<OrderBean> listByInvoice;
private Context mContext;
private ArrayList<OrderBean> orderBeanArrayList;
private int counter;

public OrderAdapter(Context context, ArrayList<OrderBean> orderBeanArrayList) {
    this.orderBeanArrayList = orderBeanArrayList;
    this.mContext = context;

    listByInvoice = new ArrayList<>();
}

@Override
public ItemRowHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
    View v;

    v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_order, viewGroup, false);
    v.setLayoutParams(new RecyclerView.LayoutParams(
            RecyclerView.LayoutParams.MATCH_PARENT,
            RecyclerView.LayoutParams.WRAP_CONTENT
    ));
    ItemRowHolder mh = new ItemRowHolder(v, mContext);
    return mh;

}


@Override
public void onBindViewHolder(final ItemRowHolder itemRowHolder, final int i) {

    if (i < orderBeanArrayList.size() - 1) {
        int menulist = orderBeanArrayList.get(i).getOrderMenuBeanArrayList().size();
        int boxlist = orderBeanArrayList.get(i).getOrderBoxBeanArrayList().size();
        int customerlist = orderBeanArrayList.get(i).getOrderBoxBeanArrayList().size();

        for (int k = 0; k < menulist; k++) {


        }
        for (int m = 0; m < boxlist; m++) {

        }
    } else {
        Log.e("LAST", "");
    }


}

@Override
public int getItemCount() {

    return orderBeanArrayList.size();
}

@Override
public int getItemViewType(int position) {

    return super.getItemViewType(position);

}

public class ItemRowHolder extends RecyclerView.ViewHolder {

    TextView tv_serviceType;
    TextView tv_PackageTitle, tv_DATE, tv_TIME, tv_TOTAL_PRICE, tv_Status, tv_orderdatetime;
    TextView tv_BoxTitle, tv_BoxDATE, tv_BoxTIME, tv_Box_TOTAL_PRICE, tv_Box_orderdatetime, tv_Box_Status;
    LinearLayout linear_box, linear_service, ll_menu, ll_box;
    CardView cardView_header;
    Button btn_viewMenu, btn_viewDetail;

    public ItemRowHolder(View view, final Context mContextv) {
        super(view);

        tv_serviceType = (TextView) view.findViewById(R.id.tv_serviceType);
        tv_PackageTitle = (TextView) view.findViewById(R.id.tv_PackageTitle);
        tv_DATE = (TextView) view.findViewById(R.id.tv_DATE);
        tv_TIME = (TextView) view.findViewById(R.id.tv_TIME);
        tv_TOTAL_PRICE = (TextView) view.findViewById(R.id.tv_TOTAL_PRICE);
        tv_Status = (TextView) view.findViewById(R.id.tv_Status);
        tv_orderdatetime = (TextView) view.findViewById(R.id.tv_orderdatetime);

        tv_BoxTitle = (TextView) view.findViewById(R.id.tv_BoxTitle);
        tv_BoxDATE = (TextView) view.findViewById(R.id.tv_BoxDATE);
        tv_BoxTIME = (TextView) view.findViewById(R.id.tv_BoxTIME);
        tv_Box_TOTAL_PRICE = (TextView) view.findViewById(R.id.tv_Box_TOTAL_PRICE);
        tv_Box_orderdatetime = (TextView) view.findViewById(R.id.tv_Box_orderdatetime);
        tv_Box_Status = (TextView) view.findViewById(R.id.tv_Box_Status);

        linear_box = (LinearLayout) view.findViewById(R.id.linear_box);
        linear_service = (LinearLayout) view.findViewById(R.id.linear_service);
        ll_menu = (LinearLayout) view.findViewById(R.id.ll_menu);
        ll_box = (LinearLayout) view.findViewById(R.id.ll_box);
        cardView_header = (CardView) view.findViewById(R.id.cardView_header);

        btn_viewMenu = (Button) view.findViewById(R.id.btn_viewMenu);
        btn_viewDetail = (Button) view.findViewById(R.id.btn_viewDetail);


    }

}

我留下了一个空白的循环,其中我已经尝试过这么多想但是它对我不起作用,我创建了动态视图但它也创造了问题。 My order look like this and every order has multiple items but they are different from each other.

0 个答案:

没有答案