//activity_main
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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" tools:context=".MainActivity"> <ScrollView android:layout_above="@+id/linear_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <!--购物车的二级列表--> <com.bwie.test.gouwuche.custom.CartExpanableListview android:id="@+id/expanable_listview" android:layout_width="match_parent" android:layout_height="wrap_content"> </com.bwie.test.gouwuche.custom.CartExpanableListview> <!--为你推荐--> <LinearLayout android:orientation="vertical" android:background="#00ff00" android:layout_width="match_parent" android:layout_height="500dp"> </LinearLayout> </LinearLayout> </ScrollView> <LinearLayout android:id="@+id/linear_layout" android:layout_alignParentBottom="true" android:gravity="center_vertical" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="50dp"> <CheckBox android:layout_marginLeft="10dp" android:button="@null" android:background="@drawable/check_box_selector" android:id="@+id/check_all" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/text_total" android:text="合计:¥0.00" android:layout_weight="2" android:layout_width="0dp" android:layout_height="wrap_content" /> <TextView android:text="去结算(0)" android:background="#ff0000" android:textColor="#ffffff" android:gravity="center" android:id="@+id/text_buy" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" /> </LinearLayout> </RelativeLayout>
//child_item_layout
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:padding="10dp" android:layout_width="match_parent" android:layout_height="match_parent"> <CheckBox android:layout_centerVertical="true" android:id="@+id/check_child" android:button="@null" android:background="@drawable/check_box_selector" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/image_good" android:layout_centerVertical="true" android:layout_toRightOf="@+id/check_child" android:layout_marginLeft="10dp" android:layout_width="80dp" android:layout_height="80dp" /> <TextView android:id="@+id/text_title" android:layout_toRightOf="@+id/image_good" android:layout_marginLeft="10dp" android:layout_alignTop="@+id/image_good" android:maxLines="2" android:minLines="2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/text_price" android:layout_toRightOf="@+id/image_good" android:layout_marginLeft="10dp" android:layout_alignBottom="@+id/image_good" android:text="¥99.99" android:textColor="#ff0000" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <LinearLayout android:layout_alignParentRight="true" android:layout_alignBottom="@+id/image_good" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/text_jian" android:text="一" android:padding="5dp" android:background="@drawable/bian_kuang_line" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:gravity="center" android:id="@+id/text_num" android:paddingLeft="10dp" android:paddingRight="10dp" android:background="@drawable/bian_kuang_line" android:layout_width="wrap_content" android:layout_height="match_parent" /> <TextView android:id="@+id/text_add" android:text="十" android:padding="5dp" android:background="@drawable/bian_kuang_line" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </RelativeLayout>
//group_item_layout
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:gravity="center_vertical" android:padding="10dp" android:layout_width="match_parent" android:layout_height="match_parent"> <CheckBox android:button="@null" android:background="@drawable/check_box_selector" android:id="@+id/check_group" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_marginLeft="10dp" android:text="京东自营" android:id="@+id/text_group" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>
//shape文件 bian_kuang_line
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#ffffff"/> <stroke android:width="0.1dp" android:color="#000000"></stroke> </shape>
//check_box_selector
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:drawable="@drawable/shopping_cart_checked"></item> <item android:state_checked="false" android:drawable="@drawable/shopping_cart_none_check"></item> <item android:drawable="@drawable/shopping_cart_checked"></item> </selector>
//添加权限
<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.application.DashApplication" </application>
//添加依赖
compile 'com.android.support:appcompat-v7:26.0.0-alpha1' testCompile 'junit:junit:4.12' compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.okio:okio:1.11.0' compile 'com.google.code.gson:gson:2.8.2' annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0' compile 'com.android.support.test:runner:0.5' compile 'com.android.support.test.espresso:espresso-core:2.2.2' compile files('libs/glide-3.7.0.jar')