本地购物车实现

来源:互联网 发布:工程预算软件下载 编辑:程序博客网 时间:2024/06/03 22:53

数据bean类格式

package moyuchen.com.shopcartspractise;import java.util.List;public class ShopCartBean {    /**     * shopId : 2     * shopName : null     * cartlist : [{"id":2,"shopId":2,"shopName":null,"productId":2,"productName":null,"color":null,"size":null,"price":null,"count":null}]     */    private int shopId;    private Object shopName;    /**     * id : 2     * shopId : 2     * shopName : null     * productId : 2     * productName : null     * color : null     * size : null     * price : null     * count : null     */    private List<CartlistBean> cartlist;    public int getShopId() {        return shopId;    }    public void setShopId(int shopId) {        this.shopId = shopId;    }    public Object getShopName() {        return shopName;    }    public void setShopName(Object shopName) {        this.shopName = shopName;    }    public List<CartlistBean> getCartlist() {        return cartlist;    }    public void setCartlist(List<CartlistBean> cartlist) {        this.cartlist = cartlist;    }    public static class CartlistBean {        private int id;        private int shopId;        private String shopName;        private int productId;        private String productName;        private String color;        private String size;        private String price;        private String defaultPic;        private int count;        private boolean isSelect = true;        private int isFirst = 2;        private boolean isShopSelect = true;        public String getDefaultPic() {            return defaultPic;        }        public void setDefaultPic(String defaultPic) {            this.defaultPic = defaultPic;        }        public boolean getIsShopSelect() {            return isShopSelect;        }        public void setShopSelect(boolean shopSelect) {            isShopSelect = shopSelect;        }        public int getIsFirst() {            return isFirst;        }        public void setIsFirst(int isFirst) {            this.isFirst = isFirst;        }        public boolean getIsSelect() {            return isSelect;        }        public void setSelect(boolean select) {            isSelect = select;        }        public int getId() {            return id;        }        public void setId(int id) {            this.id = id;        }        public int getShopId() {            return shopId;        }        public void setShopId(int shopId) {            this.shopId = shopId;        }        public String getShopName() {            return shopName;        }        public void setShopName(String shopName) {            this.shopName = shopName;        }        public int getProductId() {            return productId;        }        public void setProductId(int productId) {            this.productId = productId;        }        public String getProductName() {            return productName;        }        public void setProductName(String productName) {            this.productName = productName;        }        public String getColor() {            return color;        }        public void setColor(String color) {            this.color = color;        }        public String getSize() {            return size;        }        public void setSize(String size) {            this.size = size;        }        public String getPrice() {            return price;        }        public void setPrice(String price) {            this.price = price;        }        public int getCount() {            return count;        }        public void setCount(int count) {            this.count = count;        }    }}


RecycleView适配器

package moyuchen.com.shopcartspractise;import android.content.Context;import android.support.v7.widget.RecyclerView;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.TextView;import com.bumptech.glide.Glide;import java.util.List;/** * Created by Administrator on 2016/10/14. */public class ShopCartAdapter extends RecyclerView.Adapter<ShopCartAdapter.MyViewHolder> {    private Context context;    private List<ShopCartBean.CartlistBean> data;    private View headerView;    private OnDeleteClickListener mOnDeleteClickListener;    private OnEditClickListener mOnEditClickListener;    private OnResfreshListener mOnResfreshListener;    public ShopCartAdapter(Context context, List<ShopCartBean.CartlistBean> data){        this.context = context;        this.data = data;    }    @Override    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {        View view;        view = LayoutInflater.from(context).inflate(R.layout.item_shopcart, parent, false);        return new MyViewHolder(view);    }    @Override    public void onBindViewHolder(final MyViewHolder holder, final int position) {        Glide.with(context).load(data.get(position).getDefaultPic()).into(holder.ivShopCartClothPic);        if (position > 0) {            if (data.get(position).getShopId() == data.get(position - 1).getShopId()) {                holder.llShopCartHeader.setVisibility(View.GONE);            } else {                holder.llShopCartHeader.setVisibility(View.VISIBLE);            }        }else {            holder.llShopCartHeader.setVisibility(View.VISIBLE);        }        holder.tvShopCartClothColor.setText("颜色:" + data.get(position).getColor());        holder.tvShopCartClothSize.setText("尺寸:" + data.get(position).getSize());        holder.tvShopCartClothName.setText(data.get(position).getProductName());        holder.tvShopCartShopName.setText(data.get(position).getShopName());        holder.tvShopCartClothPrice.setText("¥" + data.get(position).getPrice());        holder.etShopCartClothNum.setText(data.get(position).getCount() + "");        if(mOnResfreshListener != null){            boolean isSelect = false;            for(int i = 0;i < data.size(); i++){                if(!data.get(i).getIsSelect()){                    isSelect = false;                    break;                }else{                    isSelect = true;                }            }            mOnResfreshListener.onResfresh(isSelect);        }        holder.ivShopCartClothMinus.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                if(data.get(position).getCount() > 1) {                    int count = data.get(position).getCount() - 1;                    if (mOnEditClickListener != null) {                        mOnEditClickListener.onEditClick(position, data.get(position).getId(), count);                    }                    data.get(position).setCount(count);                    notifyDataSetChanged();                }            }        });        holder.ivShopCartClothAdd.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                int count = data.get(position).getCount() + 1;                if(mOnEditClickListener != null){                    mOnEditClickListener.onEditClick(position,data.get(position).getId(),count);                }                data.get(position).setCount(count);                notifyDataSetChanged();            }        });        if(data.get(position).getIsSelect()){            holder.ivShopCartClothSel.setImageDrawable(context.getResources().getDrawable(R.drawable.shopcart_selected));        }else {            holder.ivShopCartClothSel.setImageDrawable(context.getResources().getDrawable(R.drawable.shopcart_unselected));        }        if(data.get(position).getIsShopSelect()){            holder.ivShopCartShopSel.setImageDrawable(context.getResources().getDrawable(R.drawable.shopcart_selected));        }else {            holder.ivShopCartShopSel.setImageDrawable(context.getResources().getDrawable(R.drawable.shopcart_unselected));        }        holder.ivShopCartClothDelete.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                showDialog(v,position);            }        });        holder.ivShopCartClothSel.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                data.get(position).setSelect(!data.get(position).getIsSelect());                //通过循环找出不同商铺的第一个商品的位置                for(int i = 0;i < data.size(); i++){                    if(data.get(i).getIsFirst() == 1) {                        //遍历去找出同一家商铺的所有商品的勾选情况                        for(int j = 0;j < data.size();j++){                            //如果是同一家商铺的商品,并且其中一个商品是未选中,那么商铺的全选勾选取消                            if(data.get(j).getShopId() == data.get(i).getShopId() && !data.get(j).getIsSelect()){                                data.get(i).setShopSelect(false);                                break;                            }else{                                //如果是同一家商铺的商品,并且所有商品是选中,那么商铺的选中全选勾选                                data.get(i).setShopSelect(true);                            }                        }                    }                }                notifyDataSetChanged();            }        });        holder.ivShopCartShopSel.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                if(data.get(position).getIsFirst() == 1) {                    data.get(position).setShopSelect(!data.get(position).getIsShopSelect());                    for(int i = 0;i < data.size();i++){                        if(data.get(i).getShopId() == data.get(position).getShopId()){                            data.get(i).setSelect(data.get(position).getIsShopSelect());                        }                    }                    notifyDataSetChanged();                }            }        });    }    private void showDialog(final View view, final int position){            //调用删除某个规格商品的接口            if(mOnDeleteClickListener != null){                mOnDeleteClickListener.onDeleteClick(view,position,data.get(position).getId());            }            data.remove(position);            //重新排序,标记所有商品不同商铺第一个的商品位置            MainActivity.isSelectFirst(data);            notifyDataSetChanged();    }    @Override    public int getItemCount() {        int count = (data == null ? 0 : data.size());        if(headerView != null){            count++;        }        return count;    }    class MyViewHolder extends RecyclerView.ViewHolder    {        private ImageView ivShopCartShopSel;        private TextView tvShopCartShopName;        private TextView tvShopCartClothName;        private TextView tvShopCartClothPrice;        private TextView etShopCartClothNum;        private TextView tvShopCartClothColor;        private TextView tvShopCartClothSize;        private ImageView ivShopCartClothSel;        private ImageView ivShopCartClothMinus;        private ImageView ivShopCartClothAdd;        private ImageView ivShopCartClothDelete;        private ImageView ivShopCartClothPic;        private LinearLayout llShopCartHeader;        public MyViewHolder(View view)        {            super(view);            llShopCartHeader = (LinearLayout) view.findViewById(R.id.ll_shopcart_header);            ivShopCartShopSel = (ImageView) view.findViewById(R.id.iv_item_shopcart_shopselect);            tvShopCartShopName = (TextView) view.findViewById(R.id.tv_item_shopcart_shopname);            tvShopCartClothName = (TextView) view.findViewById(R.id.tv_item_shopcart_clothname);            tvShopCartClothPrice = (TextView) view.findViewById(R.id.tv_item_shopcart_cloth_price);            etShopCartClothNum = (TextView) view.findViewById(R.id.et_item_shopcart_cloth_num);            tvShopCartClothColor = (TextView) view.findViewById(R.id.tv_item_shopcart_cloth_color);            tvShopCartClothSize = (TextView) view.findViewById(R.id.tv_item_shopcart_cloth_size);            ivShopCartClothSel = (ImageView) view.findViewById(R.id.tv_item_shopcart_clothselect);            ivShopCartClothMinus = (ImageView) view.findViewById(R.id.iv_item_shopcart_cloth_minus);            ivShopCartClothAdd = (ImageView) view.findViewById(R.id.iv_item_shopcart_cloth_add);            ivShopCartClothPic = (ImageView) view.findViewById(R.id.iv_item_shopcart_cloth_pic);            ivShopCartClothDelete = (ImageView) view.findViewById(R.id.iv_item_shopcart_cloth_delete);        }    }    public View getHeaderView(){        return headerView;    }    private OnItemClickListener mOnItemClickListener;    public interface OnItemClickListener{        void onItemClick(View view, int position);    }    public void setOnItemClickListener(OnItemClickListener mOnItemClickListener){        this.mOnItemClickListener = mOnItemClickListener;    }    public interface OnDeleteClickListener{        void onDeleteClick(View view, int position, int cartid);    }    public void setOnDeleteClickListener(OnDeleteClickListener mOnDeleteClickListener){        this.mOnDeleteClickListener = mOnDeleteClickListener;    }    public interface OnEditClickListener{        void onEditClick(int position, int cartid, int count);    }    public void setOnEditClickListener(OnEditClickListener mOnEditClickListener){        this.mOnEditClickListener = mOnEditClickListener;    }    public interface OnResfreshListener{        void onResfresh(boolean isSelect);    }    public void setResfreshListener(OnResfreshListener mOnResfreshListener){        this.mOnResfreshListener = mOnResfreshListener;    }}

MainActivity类的代码


package moyuchen.com.shopcartspractise;import android.graphics.drawable.Drawable;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.support.v7.widget.LinearLayoutManager;import android.support.v7.widget.RecyclerView;import android.support.v7.widget.Toolbar;import android.view.View;import android.widget.LinearLayout;import android.widget.RelativeLayout;import android.widget.TextView;import com.example.vpcsd.shopcartlogic.bean.ShopCartBean;import java.util.ArrayList;import java.util.List;public class MainActivity extends AppCompatActivity {    private TextView tvShopCartSubmit,tvShopCartSelect,tvShopCartTotalNum;    private View mEmtryView;    private RecyclerView rlvShopCart,rlvHotProducts;    private ShopCartAdapter mShopCartAdapter;    private LinearLayout llPay;    private RelativeLayout rlHaveProduct;    private List<ShopCartBean.CartlistBean> mAllOrderList = new ArrayList<>();    private ArrayList<ShopCartBean.CartlistBean> mGoPayList = new ArrayList<>();    private List<String> mHotProductsList = new ArrayList<>();    private TextView tvShopCartTotalPrice;    private int mCount,mPosition;    private float mTotalPrice1;    private boolean mSelect;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        tvShopCartSelect = (TextView) findViewById(R.id.tv_shopcart_addselect);        tvShopCartTotalPrice = (TextView) findViewById(R.id.tv_shopcart_totalprice);        tvShopCartTotalNum = (TextView) findViewById(R.id.tv_shopcart_totalnum);        rlHaveProduct = (RelativeLayout) findViewById(R.id.rl_shopcart_have);        rlvShopCart = (RecyclerView) findViewById(R.id.rlv_shopcart);        mEmtryView = (View) findViewById(R.id.emtryview);        mEmtryView.setVisibility(View.GONE);        llPay = (LinearLayout) findViewById(R.id.ll_pay);        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);        lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);        llPay.setLayoutParams(lp);        tvShopCartSubmit = (TextView) findViewById(R.id.tv_shopcart_submit);        rlvShopCart.setLayoutManager(new LinearLayoutManager(this));        mShopCartAdapter = new ShopCartAdapter(this,mAllOrderList);        rlvShopCart.setAdapter(mShopCartAdapter);        //删除商品接口        mShopCartAdapter.setOnDeleteClickListener(new ShopCartAdapter.OnDeleteClickListener() {            @Override            public void onDeleteClick(View view, int position,int cartid) {                mShopCartAdapter.notifyDataSetChanged();            }        });        //修改数量接口        mShopCartAdapter.setOnEditClickListener(new ShopCartAdapter.OnEditClickListener() {            @Override            public void onEditClick(int position, int cartid, int count) {                mCount = count;                mPosition = position;            }        });        //实时监控全选按钮        mShopCartAdapter.setResfreshListener(new ShopCartAdapter.OnResfreshListener() {            @Override            public void onResfresh( boolean isSelect) {                mSelect = isSelect;                if(isSelect){                    Drawable left = getResources().getDrawable(R.drawable.shopcart_selected);                    tvShopCartSelect.setCompoundDrawablesWithIntrinsicBounds(left,null,null,null);                }else {                    Drawable left = getResources().getDrawable(R.drawable.shopcart_unselected);                    tvShopCartSelect.setCompoundDrawablesWithIntrinsicBounds(left,null,null,null);                }                float mTotalPrice = 0;                int mTotalNum = 0;                mTotalPrice1 = 0;                mGoPayList.clear();                for(int i = 0;i < mAllOrderList.size(); i++)                    if(mAllOrderList.get(i).getIsSelect()) {                        mTotalPrice += Float.parseFloat(mAllOrderList.get(i).getPrice()) * mAllOrderList.get(i).getCount();                        mTotalNum += 1;                        mGoPayList.add(mAllOrderList.get(i));                    }                mTotalPrice1 = mTotalPrice;                tvShopCartTotalPrice.setText("总价:" + mTotalPrice);                tvShopCartTotalNum.setText("共" + mTotalNum + "件商品");            }        });        //全选        tvShopCartSelect.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                mSelect = !mSelect;                if(mSelect){                    Drawable left = getResources().getDrawable(R.drawable.shopcart_selected);                    tvShopCartSelect.setCompoundDrawablesWithIntrinsicBounds(left,null,null,null);                    for(int i = 0;i < mAllOrderList.size();i++){                        mAllOrderList.get(i).setSelect(true);                        mAllOrderList.get(i).setShopSelect(true);                    }                }else{                    Drawable left = getResources().getDrawable(R.drawable.shopcart_unselected);                    tvShopCartSelect.setCompoundDrawablesWithIntrinsicBounds(left,null,null,null);                    for(int i = 0;i < mAllOrderList.size();i++){                        mAllOrderList.get(i).setSelect(false);                        mAllOrderList.get(i).setShopSelect(false);                    }                }                mShopCartAdapter.notifyDataSetChanged();            }        });        initData();        mShopCartAdapter.notifyDataSetChanged();    }    private void initData(){        for(int i = 0;i < 2;i ++){            ShopCartBean.CartlistBean sb = new ShopCartBean.CartlistBean();            sb.setShopId(1);            sb.setPrice("1.0");            sb.setDefaultPic("http://img2.3lian.com/2014/c7/25/d/40.jpg");            sb.setProductName("狼牙龙珠鼠标");            sb.setShopName("狼牙龙珠");            sb.setColor("蓝色");            sb.setCount(2);            mAllOrderList.add(sb);        }        for(int i = 0;i < 2;i ++){            ShopCartBean.CartlistBean sb = new ShopCartBean.CartlistBean();            sb.setShopId(2);            sb.setPrice("1.0");            sb.setDefaultPic("http://img2.3lian.com/2014/c7/25/d/40.jpg");            sb.setProductName("达尔优鼠标");            sb.setShopName("达尔优");            sb.setColor("绿色");            sb.setCount(2);            mAllOrderList.add(sb);        }        isSelectFirst(mAllOrderList);    }    public static void isSelectFirst(List<ShopCartBean.CartlistBean> list){        if(list.size() > 0) {            list.get(0).setIsFirst(1);            for (int i = 1; i < list.size(); i++) {                if (list.get(i).getShopId() == list.get(i - 1).getShopId()) {                    list.get(i).setIsFirst(2);                } else {                    list.get(i).setIsFirst(1);                }            }        }    }}

条目布局文件

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="wrap_content"    android:background="@color/main_white_text">    <LinearLayout        android:id="@+id/ll_shopcart_header"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:orientation="vertical"        >        <View            android:layout_width="match_parent"            android:layout_height="@dimen/margin_10dp"            android:background="@color/background_color"            android:id="@+id/view"></View>        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:gravity="center_vertical"            >            <ImageView                android:id="@+id/iv_item_shopcart_shopselect"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:src="@drawable/shopcart_selected"                android:paddingLeft="@dimen/margin_15dp"                android:paddingRight="@dimen/margin_15dp"                android:paddingTop="@dimen/margin_10dp"                android:paddingBottom="@dimen/margin_10dp"                />            <TextView                android:id="@+id/tv_item_shopcart_shopname"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:drawableLeft="@drawable/shopcart_shop"                android:text="宝儿家服装"                android:padding="@dimen/padding_10dp"                android:drawablePadding="@dimen/padding_5dp"                />        </LinearLayout>    </LinearLayout>    <LinearLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:gravity="center_vertical"        >        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="vertical"            >            <View                android:layout_width="match_parent"                android:layout_height="@dimen/margin_1dp"                android:background="@color/background_color"                ></View>            <LinearLayout                android:layout_width="match_parent"                android:layout_height="wrap_content">                <ImageView                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:src="@drawable/shopcart_selected"                    android:layout_marginLeft="@dimen/margin_15dp"                    android:layout_marginRight="@dimen/margin_15dp"                    android:visibility="invisible"                    />                <TextView                    android:id="@+id/tv_item_shopcart_clothname"                    android:layout_width="match_parent"                    android:layout_height="wrap_content"                    android:text="穿秋装情侣字母徽章风衣"                    android:paddingLeft="@dimen/padding_10dp"                    android:paddingTop="@dimen/padding_10dp"                    />            </LinearLayout>            <LinearLayout                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:orientation="horizontal"                android:gravity="center_vertical"                >                <ImageView                    android:id="@+id/tv_item_shopcart_clothselect"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:src="@drawable/shopcart_selected"                    android:padding="@dimen/margin_15dp"                    />                <ImageView                    android:id="@+id/iv_item_shopcart_cloth_pic"                    android:layout_width="60dp"                    android:layout_height="60dp"                    android:layout_margin="@dimen/margin_10dp"                    />                <LinearLayout                    android:layout_width="0dp"                    android:layout_height="wrap_content"                    android:layout_weight="1"                    android:orientation="vertical"                    >                    <TextView                        android:id="@+id/tv_item_shopcart_cloth_price"                        android:layout_width="wrap_content"                        android:layout_height="wrap_content"                        android:text="¥185"                        android:textColor="@color/main_red_text"                        android:textSize="@dimen/common_font_size_14"                        />                    <LinearLayout                        android:layout_width="wrap_content"                        android:layout_height="wrap_content"                        android:layout_marginTop="@dimen/margin_5dp"                        android:layout_marginBottom="@dimen/margin_5dp"                        >                        <TextView                            android:id="@+id/tv_item_shopcart_cloth_color"                            android:layout_width="wrap_content"                            android:layout_height="wrap_content"                            android:text="颜色:黑色"                            android:textSize="@dimen/common_font_size_12"                            />                        <TextView                            android:id="@+id/tv_item_shopcart_cloth_size"                            android:layout_width="wrap_content"                            android:layout_height="wrap_content"                            android:text="尺寸:XL"                            android:textSize="@dimen/common_font_size_12"                            android:layout_marginLeft="@dimen/margin_10dp"                            />                    </LinearLayout>                    <LinearLayout                        android:layout_width="match_parent"                        android:layout_height="wrap_content"                        android:gravity="center_vertical"                        >                        <ImageView                            android:id="@+id/iv_item_shopcart_cloth_minus"                            android:layout_width="wrap_content"                            android:layout_height="wrap_content"                            android:src="@drawable/shopcart_minus_grey"                            />                        <TextView                            android:id="@+id/et_item_shopcart_cloth_num"                            android:layout_width="wrap_content"                            android:layout_height="wrap_content"                            android:paddingTop="@dimen/padding_2dp"                            android:paddingBottom="@dimen/padding_2dp"                            android:paddingLeft="@dimen/padding_20dp"                            android:paddingRight="@dimen/padding_20dp"                            android:background="@drawable/shopcart_add_btn"                            android:layout_marginLeft="@dimen/margin_5dp"                            android:text="1"                            />                        <ImageView                            android:id="@+id/iv_item_shopcart_cloth_add"                            android:layout_width="wrap_content"                            android:layout_height="wrap_content"                            android:src="@drawable/shopcart_add_red"                            android:layout_marginLeft="@dimen/margin_5dp"                            />                    </LinearLayout>                </LinearLayout>                <View                    android:layout_width="@dimen/margin_1dp"                    android:layout_height="match_parent"                    android:layout_marginTop="@dimen/padding_10dp"                    android:layout_marginBottom="@dimen/padding_10dp"                    android:background="@color/splitline_color"                    ></View>                <ImageView                    android:id="@+id/iv_item_shopcart_cloth_delete"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:padding="@dimen/margin_20dp"                    android:src="@drawable/shopcart_delete"                    />            </LinearLayout>        </LinearLayout>    </LinearLayout>    <View        android:layout_width="match_parent"        android:layout_height="@dimen/margin_1dp"        android:background="@color/background_color"        ></View></LinearLayout>MainActivity类中布局文件<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent">    <RelativeLayout        android:id="@+id/rl_shopcart_have"        android:layout_width="match_parent"        android:layout_height="match_parent">        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="vertical"            >            <android.support.v7.widget.RecyclerView                android:id="@+id/rlv_shopcart"                android:layout_width="match_parent"                android:layout_height="0dp"                android:layout_weight="1"                ></android.support.v7.widget.RecyclerView>            <View                android:layout_width="match_parent"                android:layout_height="50dp">            </View>        </LinearLayout>        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="horizontal"            android:background="@color/main_white_text"            android:gravity="center_vertical"            android:id="@+id/ll_pay"            android:layout_above="@+id/emtryview"            >            <TextView                android:id="@+id/tv_shopcart_addselect"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_marginLeft="@dimen/margin_10dp"                android:drawableLeft="@drawable/shopcart_selected"                android:text="全选"                android:drawablePadding="@dimen/padding_5dp"                />            <LinearLayout                android:layout_width="0dp"                android:layout_height="wrap_content"                android:layout_weight="1"                android:orientation="vertical"                >                <TextView                    android:id="@+id/tv_shopcart_totalprice"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:paddingLeft="@dimen/padding_10dp"                    android:paddingTop="@dimen/padding_10dp"                    android:text="总价:¥0"                    android:textColor="@color/main_red_text"                    android:textSize="@dimen/common_font_size_16"                    />                <TextView                    android:id="@+id/tv_shopcart_totalnum"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:paddingLeft="@dimen/padding_10dp"                    android:text="共0件商品"                    android:textSize="@dimen/common_font_size_14"                    android:paddingBottom="@dimen/padding_10dp"                    />            </LinearLayout>            <TextView                android:id="@+id/tv_shopcart_submit"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:background="@drawable/login_btn"                android:text="去结算"                android:paddingLeft="@dimen/margin_30dp"                android:paddingRight="@dimen/margin_30dp"                android:paddingTop="@dimen/padding_10dp"                android:paddingBottom="@dimen/padding_10dp"                android:textColor="@color/main_white_text"                android:layout_marginRight="@dimen/margin_10dp"                />        </LinearLayout>        <View            android:id="@+id/emtryview"            android:layout_width="match_parent"            android:layout_alignParentBottom="true"            android:layout_height="50dp">        </View>    </RelativeLayout></LinearLayout>


 
原创粉丝点击