依赖
//okhttp compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.okio:okio:1.11.0' //gson compile 'com.google.code.gson:gson:2.8.2' //glide implementation 'com.github.bumptech.glide:glide:4.4.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'权限
<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"/>布局
activity
<?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="bwie.com.xiaigouwuche.MainActivity"> <ScrollView android:layout_above="@+id/linear_bottom" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--二级列表--> <bwie.com.xiaigouwuche.MyExpanableListView android:id="@+id/expanable_list_view" android:layout_width="match_parent" android:layout_height="wrap_content"> </bwie.com.xiaigouwuche.MyExpanableListView> <TextView android:layout_width="match_parent" android:layout_height="400dp" android:text="为你推荐" android:layout_marginTop="10dp" android:layout_gravity="center_horizontal" android:background="#00ff00"/> </LinearLayout> </ScrollView> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/relative_progress" android:visibility="gone" android:layout_above="@+id/linear_bottom"> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true"/> </RelativeLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="50dp" android:orientation="horizontal" android:layout_alignParentBottom="true" android:id="@+id/linear_bottom"> <CheckBox android:button="@null" android:background="@drawable/check_box_selector" android:layout_marginLeft="10dp" 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_gravity="center_vertical" android:layout_marginLeft="10dp" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" /> <TextView android:id="@+id/text_buy" android:background="#ff0000" android:textColor="#ffffff" android:gravity="center" android:text="去结算(0)" android:layout_width="100dp" android:layout_height="match_parent" /> </LinearLayout> </RelativeLayout>child_layout
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:id="@+id/child_check" android:background="@drawable/check_box_selector" android:button="@null"/> <ImageView android:layout_marginLeft="10dp" android:layout_toRightOf="@+id/child_check" android:id="@+id/child_image" android:layout_width="100dp" android:layout_height="100dp" /> <TextView android:maxLines="2" android:minLines="2" android:id="@+id/child_title" android:layout_marginLeft="5dp" android:layout_toLeftOf="@+id/text_delete" android:layout_toRightOf="@+id/child_image" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/child_price" android:textColor="#ff0000" android:text="¥0.00" android:layout_toRightOf="@+id/child_image" android:layout_alignBottom="@+id/child_image" android:layout_marginLeft="5dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <LinearLayout android:id="@+id/linearLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/child_image" android:layout_toLeftOf="@+id/text_delete" android:orientation="horizontal"> <TextView android:id="@+id/text_jian" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/bian_kuang" android:padding="5dp" android:text="-" /> <TextView android:id="@+id/text_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/bian_kuang" android:paddingBottom="5dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="5dp" android:text="1" /> <TextView android:id="@+id/text_add" android:layout_width="wrap_content" android:layout_height="wrap_content"