您的位置:首页 > 其它

二级列表展示购物车MVP

2017-11-22 10:31 369 查看
声明:Bean包可能需要手动添加checked属性和num计算属性。
首先导入依赖:compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'compile 'org.greenrobot:eventbus:3.1.1'compile 'com.google.code.gson:gson:2.8.2'compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'compile 'io.github.openfeign:feign-gson:9.5.1'
net包:HttpUtils类
package bwie.com.singleshoppingcart.net;import okhttp3.Callback;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.logging.HttpLoggingInterceptor;/*** Created by admin on 2017/11/21.*/public class HttpUtils {private static volatile HttpUtils httpUtils;private OkHttpClient client;private HttpUtils(){HttpLoggingInterceptor logging = new HttpLoggingInterceptor();logging.setLevel(HttpLoggingInterceptor.Level.BODY);client = new OkHttpClient.Builder().addInterceptor(logging).build();}public static HttpUtils getHttpUtils(){if (httpUtils == null){synchronized (HttpUtils.class){if (httpUtils == null){httpUtils = new HttpUtils();}}}return httpUtils;}public void doGet(String url, Callback callback){Request request = new Request.Builder().url(url).build();client.newCall(request).enqueue(callback);}}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Api:Url地址
package bwie.com.singleshoppingcart.net;/*** Created by admin on 2017/11/21.*/public interface Api {public static final String url = "http://result.eolinker.com/iYXEPGn4e9c6dafce6e5cdd23287d2bb136ee7e9194d3e9?uri=evaluation";}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
OnNetListener:接口回调类
package bwie.com.singleshoppingcart.net;/*** Created by admin on 2017/11/21.*/public interface OnNetListener<T> {public void onSuccess(T t);public void onFilure(Exception e);}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ShopBean:bean类
package bwie.com.singleshoppingcart.bean;import java.util.List;/*** Created by admin on 2017/11/21.*/public class ShopBean {/*** code : 200* data : [{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"购买渠道:大陆国行","price":500,"type_name":"苹果 iPhone 6(白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"购买渠道:水货无锁","price":1000,"type_name":"苹果 iPhone 7 (亮黑色)","type_sn_id":"tgg"}],"title":"苹果","title_id":"59280"},{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"边框背板:全新未使用","price":50,"type_name":"小米4s (白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":100,"type_name":"小米5s (亮黑色)","type_sn_id":"tgg"}],"title":"小米","title_id":"59279"},{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"边框背板:全新未使用","price":50,"type_name":"三星 (白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":100,"type_name":"三星 (亮黑色)","type_sn_id":"tgg"}],"title":"三星","title_id":"59279"},{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"边框背板:全新未使用","price":50,"type_name":"华为 (白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":100,"type_name":"华为 (亮黑色)","type_sn_id":"tgg"},{"add_time":20000"2016-12-10 4:55:28","cart_id":"445164","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":150,"type_name":"华为 (纯黑色)","type_sn_id":"hgg"}],"title":"华为","title_id":"59279"}]* flag : Success* msg : 描述*/private boolean checked;private String code;private String flag;private String msg;private List<DataBean> data;public boolean isChecked() {return checked;}public void setChecked(boolean checked) {this.checked = checked;}public String getCode() {return code;}public void setCode(String code) {this.code = code;}public String getFlag() {return flag;}public void setFlag(String flag) {this.flag = flag;}public String getMsg() {return msg;}public void setMsg(String msg) {this.msg = msg;}public List<DataBean> getData() {return data;}public void setData(List<DataBean> data) {this.data = data;}public static class DataBean {/*** datas : [{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"购买渠道:大陆国行","price":500,"type_name":"苹果 iPhone 6(白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"购买渠道:水货无锁","price":1000,"type_name":"苹果 iPhone 7 (亮黑色)","type_sn_id":"tgg"}]* title : 苹果* title_id : 59280*/private boolean checked;private String title;private String title_id;private List<DatasBean> datas;public boolean isChecked() {return checked;}public void setChecked(boolean checked) {this.checked = checked;}public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}public String getTitle_id() {return title_id;}public void setTitle_id(String title_id) {this.title_id = title_id;}public List<DatasBean> getDatas() {return datas;}public void setDatas(List<DatasBean> datas) {this.datas = datas;}public static class DatasBean {/*** add_time : 2016-12-10 14:54:58* cart_id : 445162* house_id : 1* msg : 购买渠道:大陆国行* price : 500* type_name : 苹果 iPhone 6(白金色)* type_sn_id : ggh*/private boolean checked;private int num = 1;private String add_time;private String cart_id;private String house_id;private String msg;private int price;private String type_name;private String type_sn_id;public int getNum() {return num;}public void setNum(int num) {this.num = num;}public boolean isChecked() {return checked;}public void setChecked(boolean checked) {this.checked = checked;}public String getAdd_time() {return add_time;}public void setAdd_time(String add_time) {this.add_time = add_time;}public String getCart_id() {return cart_id;}public void setCart_id(String cart_id) {this.cart_id = cart_id;}public String getHouse_id() {return house_id;}public void setHouse_id(String house_id) {this.house_id = house_id;}public String getMsg() {return msg;}public void setMsg(String msg) {this.msg = msg;}public int getPrice() {return price;}public void setPrice(int price) {this.price = price;}public String getType_name() {return type_name;}public void setType_name(String type_name) {this.type_name = type_name;}public String getType_sn_id() {return type_sn_id;}public void setType_sn_id(String type_sn_id) {this.type_sn_id = type_sn_id;}}}}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
MVP:model层接口类:IShopModel:
package bwie.com.singleshoppingcart.model;import bwie.com.singleshoppingcart.bean.ShopBean;import bwie.com.singleshoppingcart.net.OnNetListener;/*** Created by admin on 2017/11/21.*/public interface IShopModel {public void getGoods(OnNetListener<ShopBean> onNetListener);}
MVP:model层:ShopModel:
package bwie.com.singleshoppingcart.model;import android.os.Handler;import android.os.Looper;import com.google.gson.Gson;import java.io.IOException;import bwie.com.singleshoppingcart.bean.ShopBean;import bwie.com.singleshoppingcart.net.Api;import bwie.com.singleshoppingcart.net.HttpUtils;import bwie.com.singleshoppingcart.net.OnNetListener;import okhttp3.Call;import okhttp3.Callback;import okhttp3.Response;/*** Created by admin on 2017/11/21.*/public class ShopModel implements IShopModel {private Handler handler = new Handler(Looper.getMainLooper());@Overridepublic void getGoods(final OnNetListener<ShopBean> onNetListener) {HttpUtils.getHttpUtils().doGet(Api.url, new Callback() {@Overridepublic void onFailure(Call call, IOException e) {}@Overridepublic void onResponse(Call call, Response response) throws IOException {String string = response.body().string();final ShopBean shopBean = new Gson().fromJson(string, ShopBean.class);handler.post(new Runnable() {@Overridepublic void run() {onNetListener.onSuccess(shopBean);}});}});}}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
MVP:Presenter层:shopPresenter:
package bwie.com.singleshoppingcart.presenter;import java.util.ArrayList;import java.util.List;import bwie.com.singleshoppingcart.bean.ShopBean;import bwie.com.singleshoppingcart.model.ShopModel;import bwie.com.singleshoppingcart.net.OnNetListener;import bwie.com.singleshoppingcart.view.IMainActivity;/*** Created by admin on 2017/11/21.*/public class ShopPresenter {private ShopModel shopModel;private IMainActivity iMainActivity;public ShopPresenter(IMainActivity iMainActivity) {this.iMainActivity = iMainActivity;shopModel = new ShopModel();}public void getGoods(){shopModel.getGoods(new OnNetListener<ShopBean>() {@Overridepublic void onSuccess(ShopBean shopBean) {List<ShopBean.DataBean> data = shopBean.getData();List<List<ShopBean.DataBean.DatasBean>> childList = new ArrayList<List<ShopBean.DataBean.DatasBean>>();for (int i = 0; i < data.size(); i++){List<ShopBean.DataBean.DatasBean> datas = data.get(i).getDatas();childList.add(datas);}iMainActivity.getGoods(data, childList);}@Overridepublic void onFilure(Exception e) {}});}}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
View层:MainActivity:
package bwie.com.singleshoppingcart.view;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.CheckBox;import android.widget.ExpandableListView;import android.widget.TextView;import org.greenrobot.eventbus.EventBus;import org.greenrobot.eventbus.Subscribe;import java.util.List;import bwie.com.singleshoppingcart.R;import bwie.com.singleshoppingcart.adapter.MyAdapter;import bwie.com.singleshoppingcart.bean.ShopBean;import bwie.com.singleshoppingcart.eventbus.EventbusMessage;import bwie.com.singleshoppingcart.eventbus.PriceAndCountEvent;import bwie.com.singleshoppingcart.presenter.ShopPresenter;public class MainActivity extends AppCompatActivity implements IMainActivity{private ExpandableListView elv;private CheckBox checkBox2;private TextView tv_price;private TextView tv_num;private MyAdapter adapter;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);new ShopPresenter(this).getGoods();initView();EventBus.getDefault().register(this);checkBox2.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {adapter.changeAllListCbState(checkBox2.isChecked());}});}@Overrideprotected void onDestroy() {super.onDestroy();EventBus.getDefault().unregister(this);}private void initView() {//初始化组件elv = (ExpandableListView) findViewById(R.id.elv);checkBox2 = (CheckBox) findViewById(R.id.checkbox2);tv_price = (TextView) findViewById(R.id.tv_price);tv_num = (TextView) findViewById(R.id.tv_num);}@Overridepublic void getGoods(List<ShopBean.DataBean> groupList, List<List<ShopBean.DataBean.DatasBean>> childList) {adapter = new MyAdapter(this, groupList, childList);elv.setAdapter(adapter);elv.setGroupIndicator(null);for (int i = 0; i < groupList.size(); i++){elv.expandGroup(i);}}@Subscribepublic void onMessageEvent(EventbusMessage event) {checkBox2.setChecked(event.isChecked());}@Subscribepublic void onMessageEvent(PriceAndCountEvent event) {tv_num.setText("结算(" + event.getCount() + ")");tv_price.setText(event.getPrice() + "");}}
View层:MainActivity接口类IMainActivity
package bwie.com.singleshoppingcart.view;import java.util.List;import bwie.com.singleshoppingcart.bean.ShopBean;/*** Created by admin on 2017/11/21.*/public interface IMainActivity {public void getGoods(List<ShopBean.DataBean> groupList, List<List<ShopBean.DataBean.DatasBean>> childList);}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EventBus包:EventBusMessage类:
package bwie.com.singleshoppingcart.eventbus;/*** Created by admin on 2017/11/21.*/public class EventbusMessage {private boolean checked;public boolean isChecked() {return checked;}public void setChecked(boolean checked) {this.checked = checked;}}
计算钱数和数量的方法
package bwie.com.singleshoppingcart.eventbus;/*** Created by admin on 2017/11/21.*/public class PriceAndCountEvent {private int price;private int count;public int getPrice() {return price;}public void setPrice(int price) {this.price = price;}public int getCount() {return count;}public void setCount(int count) {this.count = count;}}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
二级列表适配器:(易错点)
package bwie.com.singleshoppingcart.adapter;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.BaseExpandableListAdapter;import android.widget.CheckBox;import android.widget.ImageView;import android.widget.TextView;import org.greenrobot.eventbus.EventBus;import java.util.List;import bwie.com.singleshoppingcart.R;import bwie.com.singleshoppingcart.bean.ShopBean;import bwie.com.singleshoppingcart.eventbus.EventbusMessage;import bwie.com.singleshoppingcart.eventbus.PriceAndCountEvent;/*** Created by peng on 2017/11/16.*/public class MyAdapter extends BaseExpandableListAdapter {private Context context;private List<ShopBean.DataBean> groupList;private List<List<ShopBean.DataBean.DatasBean>> childList;private final LayoutInflater inflater;public MyAdapter(Context context, List<ShopBean.DataBean> groupList, List<List<ShopBean.DataBean.DatasBean>> childList) {this.context = context;this.groupList = groupList;this.childList = childList;inflater = LayoutInflater.from(context);}@Overridepublic int getGroupCount() {return groupList.size();}@Overridepublic int getChildrenCount(int groupPosition) {return childList.get(groupPosition).size();}@Overridepublic Object getGroup(int groupPosition) {return groupList.get(groupPosition);}@Overridepublic Object getChild(int groupPosition, int childPosition) {return childList.get(groupPosition).get(childPosition);}@Overridepublic long getGroupId(int groupPosition) {return groupPosition;}@Overridepublic long getChildId(int groupPosition, int childPosition) {return childPosition;}@Overridepublic boolean hasStableIds() {return false;}@Overridepublic View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {View view;final GroupViewHolder holder;if (convertView == null) {holder = new GroupViewHolder();view = inflater.inflate(R.layout.group_list_item, null);holder.cbGroup = (CheckBox) view.findViewById(R.id.cb_parent);holder.tv_number = (TextView) view.findViewById(R.id.tv_number);view.setTag(holder);} else {view = convertView;holder = (GroupViewHolder) view.getTag();}final ShopBean.DataBean dataBean = groupList.get(groupPosition);holder.cbGroup.setChecked(dataBean.isChecked());holder.tv_number.setText(dataBean.getTitle());//设置一级列表监听holder.cbGroup.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {dataBean.setChecked(holder.cbGroup.isChecked());changeChildCbState(groupPosition, holder.cbGroup.isChecked());EventBus.getDefault().post(compute());changeAllCbState(isAllGroupCbSelected());notifyDataSetChanged();}});return view;}@Overridepublic View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {View view;final ChildViewHolder holder;if (convertView == null) {holder = new ChildViewHolder();view = inflater.inflate(R.layout.child_list_item, null);holder.cbChild = (CheckBox) view.findViewById(R.id.cb_child);holder.tv_tel = (TextView) view.findViewById(R.id.tv_tel);holder.tv_content = (TextView) view.findViewById(R.id.tv_content);holder.tv_time = (TextView) view.findViewById(R.id.tv_time);holder.tv_price = (TextView) view.findViewById(R.id.tv_pri);holder.tv_del = (TextView) view.findViewById(R.id.tv_del);holder.iv_add = (ImageView) view.findViewById(R.id.iv_add);holder.iv_del = (ImageView) view.findViewById(R.id.iv_del);holder.tv_num = (TextView) view.findViewById(R.id.tv_num);view.setTag(holder);} else {view = convertView;holder = (ChildViewHolder) view.getTag();}final ShopBean.DataBean.DatasBean datasBean = childList.get(groupPosition).get(childPosition);holder.cbChild.setChecked(datasBean.isChecked());holder.tv_tel.setText(datasBean.getType_name());holder.tv_content.setText(datasBean.getMsg());holder.tv_time.setText(datasBean.getAdd_time());holder.tv_price.setText(datasBean.getPrice() + "");holder.tv_num.setText(datasBean.getNum() + "");/*** 给二级列表设置监听*/holder.cbChild.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {datasBean.setChecked(holder.cbChild.isChecked());if (holder.cbChild.isChecked()){if (isAllChildCbSelected(groupPosition)){changeGroupCbState(groupPosition, true);changeAllCbState(isAllGroupCbSelected());}}else {changeGroupCbState(groupPosition, false);changeAllCbState(isAllGroupCbSelected());}notifyDataSetChanged();}});//加号holder.iv_add.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {int num = datasBean.getNum();holder.tv_num.setText(++num + "");datasBean.setNum(num);if (holder.cbChild.isChecked()){PriceAndCountEvent priceAndCountEvent = compute();EventBus.getDefault().post(priceAndCountEvent);}}});//减号holder.iv_del.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {int num = datasBean.getNum();if (num == 1){return;}holder.tv_num.setText(--num + "");datasBean.setNum(num);if (holder.cbChild.isChecked()){PriceAndCountEvent priceAndCountEvent = compute();EventBus.getDefault().post(priceAndCountEvent);}}});//删除holder.tv_del.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {List<ShopBean.DataBean.DatasBean> datasBeen = childList.get(groupPosition);if (datasBeen.size() == 0){childList.remove(groupPosition);groupList.remove(groupPosition);}EventBus.getDefault().post(compute());notifyDataSetChanged();}});return view;}@Overridepublic boolean isChildSelectable(int groupPosition, int childPosition) {return true;}class GroupViewHolder {CheckBox cbGroup;TextView tv_number;}class ChildViewHolder {CheckBox cbChild;TextView tv_tel;TextView tv_content;TextView tv_time;TextView tv_price;TextView tv_del;ImageView iv_del;ImageView iv_add;TextView tv_num;}//改变全选的状态private void changeAllCbState(boolean flag) {EventbusMessage eventbusMessage = new EventbusMessage();eventbusMessage.setChecked(flag);EventBus.getDefault().post(eventbusMessage);}//改变一级列表checkbox选中状态private void changeGroupCbState(int groupPosition, boolean flag){ShopBean.DataBean dataBean = groupList.get(groupPosition);dataBean.setChecked(flag);}//改变二级列表checkbox选中状态private void changeChildCbState(int groupPosition, boolean flag){List<ShopBean.DataBean.DatasBean> datasBeen = childList.get(groupPosition);for (int i = 0; i < datasBeen.size(); i++){ShopBean.DataBean.DatasBean datasBean = datasBeen.get(i);datasBean.setChecked(flag);}}//判断一级列表checkbox是否选中private boolean isAllGroupCbSelected(){for (int i = 0; i < groupList.size(); i++){ShopBean.DataBean dataBean = groupList.get(i);if (!dataBean.isChecked()){return false;}}return true;}//判断二级列表checkbox是否选中private boolean isAllChildCbSelected(int groupPosition){List<ShopBean.DataBean.DatasBean> datasBeen = childList.get(groupPosition);for (int i = 0; i < datasBeen.size(); i++){ShopBean.DataBean.DatasBean datasBean = datasBeen.get(i);if (!datasBean.isChecked()){return false;}}return true;}/*** 计算列表中,选中的钱和数量*/private PriceAndCountEvent compute() {int count = 0;int price = 0;for (int i = 0; i < childList.size(); i++) {List<ShopBean.DataBean.DatasBean> datasBeen = childList.get(i);for (int j = 0; j < datasBeen.size(); j++) {ShopBean.DataBean.DatasBean datasBean = datasBeen.get(j);if (datasBean.isChecked()) {price += datasBean.getNum() * datasBean.getPrice();count += datasBean.getNum();}}}PriceAndCountEvent priceAndCountEvent = new PriceAndCountEvent();priceAndCountEvent.setCount(count);priceAndCountEvent.setPrice(price);return priceAndCountEvent;}//设置全选,反选public void changeAllListCbState(boolean flag){for (int i = 0; i < groupList.size(); i++){changeGroupCbState(i, flag);changeChildCbState(i, flag);}EventBus.getDefault().post(compute());notifyDataSetChanged();}}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
activity_main.xml布局文件:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/activity_main"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context="bwie.com.singleshoppingcart.view.MainActivity"><TextViewandroid:layout_width="match_parent"android:layout_height="40dp"android:background="#990000ff"android:gravity="center"android:text="购物车"android:textColor="#ff3660"android:textSize="25sp" /><ExpandableListViewandroid:id="@+id/elv"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:layout_alignParentBottom="true"android:background="@android:color/white"android:gravity="center_vertical"><CheckBoxandroid:id="@+id/checkbox2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="10dp"android:focusable="false" /><TextViewandroid:layout_width="wrap_content"android:layout_height="50dp"android:layout_centerVertical="true"android:layout_marginLeft="10dp"android:layout_toRightOf="@+id/checkbox2"android:gravity="center_vertical"android:text="全选"android:textSize="20sp" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:orientation="horizontal"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="合计 :" /><TextViewandroid:id="@+id/tv_price"android:layout_width="wrap_content"android:layout_height="50dp"android:layout_marginLeft="10dp"android:paddingRight="10dp"android:text="0"android:textColor="@android:color/holo_red_light" /><TextViewandroid:id="@+id/tv_num"android:layout_width="wrap_content"android:layout_height="50dp"android:background="@android:color/holo_red_dark"android:gravity="center"android:padding="10dp"android:text="结算(0)"android:textColor="@android:color/white" /></LinearLayout></RelativeLayout></LinearLayout>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
group_list_item.xml一级列表布局文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="100dp"android:gravity="center_vertical"android:orientation="horizontal"><CheckBoxandroid:id="@+id/cb_parent"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="30dp"android:layout_marginLeft="20dp"android:layout_marginTop="30dp"android:focusable="false" /><TextViewandroid:id="@+id/tv_sign"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="标记" /><TextViewandroid:id="@+id/tv_number"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="12345678" /></LinearLayout>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
child_list_item.xml二级列表布局文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@android:color/darker_gray"android:gravity="center_vertical"android:orientation="horizontal"><CheckBoxandroid:id="@+id/cb_child"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="30dp"android:layout_marginLeft="40dp"android:layout_marginTop="30dp"android:focusable="false" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical"><TextViewandroid:id="@+id/tv_tel"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="iphone6" /><TextViewandroid:id="@+id/tv_content"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="什么手机" /><TextViewandroid:id="@+id/tv_time"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="2016-12-10" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="vertical"><TextViewandroid:id="@+id/tv_pri"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="¥3000.00" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center_vertical"><ImageViewandroid:id="@+id/iv_del"android:layout_width="20dp"android:layout_height="20dp"android:src="@drawable/shopcart_minus_grey" /><TextViewandroid:id="@+id/tv_num"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="5dp"android:background="@drawable/shopcart_add_btn"android:paddingBottom="2dp"android:paddingLeft="20dp"android:paddingRight="20dp"android:paddingTop="2dp"android:text="1" /><ImageViewandroid:id="@+id/iv_add"android:layout_width="20dp"android:layout_height="20dp"android:layout_marginLeft="5dp"android:src="@drawable/shopcart_add_red" /></LinearLayout></LinearLayout><TextViewandroid:id="@+id/tv_del"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="删除" /></LinearLayout>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
drawable目录下需要文件:
shopcart_add_btn.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"><corners android:radius="200dp"></corners><stroke android:color="@color/colorPrimaryDark" android:width="1dp"></stroke></shape>
加减按钮图片

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  class mvp url logging gson