需要的依赖和权限
compile 'com.google.code.gson:gson:2.8.2' compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.okio:okio:1.11.0' compile 'com.facebook.fresco:fresco:0.11.0' compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:name="com.bwie.test.custom.RookieApplication"
activity_order_form
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.bwie.test.orderformdemo.OrderFormActivity"> <RelativeLayout android:layout_width="match_parent" android:layout_height="50dp"> <ImageView android:layout_width="25dp" android:layout_height="25dp" android:src="@drawable/leftjiantou" android:layout_centerVertical="true" android:layout_marginLeft="10dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="购物车" android:layout_centerInParent="true"/> <TextView android:layout_width="match_parent" android:layout_height="0.1dp" android:layout_alignParentBottom="true" android:background="#000000"/> </RelativeLayout> <ExpandableListView android:id="@+id/cart_list" android:groupIndicator="@null" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </ExpandableListView> <TextView android:layout_width="match_parent" android:layout_height="0.1dp" android:background="#000000"/> <LinearLayout android:layout_width="match_parent" android:layout_height="50dp"> <LinearLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center_vertical"> <CheckBox android:id="@+id/all_check" android:layout_width="25dp" android:layout_height="25dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="全选/反选"/> <TextView android:layout_marginLeft="20dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="总价:¥" android:textColor="#FF0000"/> <TextView android:id="@+id/total_price" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0.00" android:textColor="#FF0000"/> </LinearLayout> <Button android:id="@+id/clearing" android:layout_width="80dp" android:layout_height="match_parent" android:text="去结算(0)" android:textColor="#FFFFFF" android:background="@drawable/cart_btn_bg"/> </LinearLayout> </LinearLayout>
activity_order_list
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.bwie.test.orderformdemo.OrderListActivity"> <RelativeLayout android:id="@+id/parent" android:layout_width="match_parent" android:layout_height="50dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="订单列表" android:layout_centerInParent="true"/> <ImageView android:id="@+id/status" android:layout_width="25dp" android:layout_height="25dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:src="@drawable/lv_icon" android:layout_marginRight="10dp"/> <TextView android:layout_width="match_parent" android:layout_height="0.1dp" android:layout_alignParentBottom="true" android:background="#000000"/> </RelativeLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="50dp"> <TextView android:id="@+id/unpaid" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="待支付"/> <TextView android:layout_width="1dp" android:layout_height="match_parent" android:background="#000000"/> <TextView android:id="@+id/paid" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="已支付"/> <TextView android:layout_width="1dp" android:layout_height="match_parent" android:background="#000000"/> <TextView android:id="@+id/canceled" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="已取消"/> </LinearLayout> <TextView android:layout_width="match_parent" android:layout_height="0.1dp" android:background="#000000"/> <android.support.v7.widget.RecyclerView android:id="@+id/recy" android:layout_width="match_parent" android:layout_height="match_parent"> </android.support.v7.widget.RecyclerView> </LinearLayout>
cart_child
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="100dp" android:gravity="center_vertical"> <CheckBox android:id="@+id/child_check" android:layout_width="25dp" android:layout_height="25dp" /> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/image" android:layout_marginLeft="10dp" android:layout_width="80dp" android:layout_height="80dp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="80dp" android:orientation="vertical"> <TextView android:id="@+id/child_title" android:layout_width="match_parent" android:layout_height="40dp" android:gravity="center_vertical" android:maxLines="1"/> <RelativeLayout android:layout_width="match_parent" android:layout_height="40dp"> <TextView android:id="@+id/price_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="优惠价:¥" android:textColor="#FF0000" android:layout_centerVertical="true"/> <TextView android:layout_toRightOf="@+id/price_text" android:id="@+id/bargain_price" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0.00" android:textColor="#FF0000" android:layout_centerVertical="true"/> <com.bwie.test.custom.NumberAddSubView android:id="@+id/number_view" android:layout_alignParentRight="true" android:layout_width="100dp" android:layout_height="25dp" app:value="1" app:minValue="1" app:maxValue="200" android