OkHttp请求网络数据二级列表实现购物车全选,单选,总价,增加,减少
记住要添加网络权限
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
要添加的一些依赖
compile files('libs/okhttp-3.9.0.jar')
compile files('libs/okio-1.13.0.jar')
compile files('libs/gson-2.2.4.jar')
activity_main
<?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">
<ExpandableListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:groupIndicator="@null"></ExpandableListView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<CheckBox
android:id="@+id/checkAll"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:drawablePadding="5dp"
android:text="全选"
android:textColor="#6b6868"
android:textSize="18sp" />
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/checkAll"
android:gravity="center"
android:text="合计:¥0.00"
android:textColor="#000000"
android:textSize="18sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="#ff0000">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#ff0000"
android:gravity="center"
android:paddingLeft="30dp"
android:text="去结算"
android:textColor="#ffffff"
android:textSize="22sp" />
<TextView
android:id="@+id/checked_shop"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#ff0000"
android:gravity="center"
android:paddingRight="30dp"
android:text="(0)"
android:textColor="#ffffff"
android:textSize="13sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
MainActivity
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;
public class MainActivity extends AppCompatActivity {
private ExpandableListView listview;
private MyAdpater adpater;
private TextView checked_shop;
private TextView price;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listview = (ExpandableListView) findViewById(R.id.listview);
adpater = new MyAdpater(this);
listview.setAdapter(adpater);
final CheckBox checkAll = (CheckBox) findViewById(R.id.checkAll);
price = (TextView) findViewById(R.id.price);
checked_shop = (TextView) findViewById(R.id.checked_shop);
checkAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//设置商品全部选中
adpater.checkAllShop(checkAll.isChecked());
//计算选中的价格和数量
String shopPrice = adpater.getShopPrice();
//判断商品是否全部选中
boolean b = adpater.selectAll();
String[] split = shopPrice.split(",");
price.setText(split[0]);
checked_shop.setText(split[1]);
checkAll.setChecked(b);
}
});
adpater.getAdapterData(new MyAdpater.AdapterData() {
@Override
public void Data(View v, String str, boolean b) {
String[] split = str.split(",");
price.setText(split[0]);
checked_shop.setText(split[1]);
checkAll.setChecked(b);
}
});
checkAll.setChecked(adpater.selectAll());
adpater.notifyDataSetChanged();
}
}
OkHttp的封装1
import android.os.Handler;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
public class OkHttpUtils {
private Handler handler = new Handler();
public Handler getHandler(){
return handler;
}
//单例
private static OkHttpUtils okHttpUtils = new OkHttpUtils();
private OkHttpUtils(){};
public static OkHttpUtils getInstance(){
return okHttpUtils;
}
private OkHttpClient client;
//
private OkHttpClient getOkHttpClient() {
synchronized (OkHttpUtils.class) {
if (client == null) {
client = new OkHttpClient();
}
}
return client;
}
//公用的get请求方法 完成的功能不确定
public void doGet(String url, Callback callback){
OkHttpClient okHttpClient = getOkHttpClient();
Request request = new Request.Builder().url(url).build();
Call call = okHttpClient.newCall(request);
call.enqueue(callback);
}
public void doPost(String url, Map<String,String> map, Callback callback){
OkHttpClient okHttpClient = getOkHttpClient();
FormBody.Builder builder = new FormBody.Builder();
//遍历map集合 设置请求体
for (String mapKey : map.keySet()){
builder.add(mapKey,map.get(mapKey));
}
//设置请求方式
Request request = new Request.Builder().url(url).post(builder.build()).build();
//执行请求方式 接口回调
okHttpClient.newCall(request).enqueue(callback);
}
/**
*1.下载地址
*/
public void doDown(String url,Callback callback){
OkHttpClient okHttpClient = getOkHttpClient();
Request build = new Request.Builder().url(url).build();
okHttpClient.newCall(build).enqueue(callback);
}
}
OnUiCallback OkHttp的封装2
import android.os.Handler;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public abstract class OnUiCallback implements Callback{
private Handler handler = OkHttpUtils.getInstance().getHandler();
public abstract void onFailed(Call call, IOException e);
public abstract void onSuccess(String result) throws IOException;
@Override
public void onFailure(final Call call, final IOException e) {
//该方式 存在问题 网络请求也跑到了主线程 待解决
//该方法就是把 线程post到handler所在的线程
handler.post(new Runnable() {
@Override
public void run() {
onFailed(call, e);
}
});
}
@Override
public void onResponse(final Call call, final Response response) throws IOException {
final String result = response.body().string();
//该方式 存在问题 网络请求也跑到了主线程 待解决
handler.post(new Runnable() {
@Override
public void run() {
try {
onSuccess(result);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}
MyAdpater适配器
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
import com.example.mycar.Beans.Max;
import com.example.mycar.Utils.OkHttpUtils;
import com.example.mycar.Utils.OnUiCallback;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import okhttp3.Call;
public class MyAdpater extends BaseExpandableListAdapter {
private Context context;
private String[] group;
private String[][] child;
private HashMap<Integer, Boolean> groupHashMap;
private List<HashMap<Integer, Boolean>> childList;
private List<List<Bean>> dataList;
List<Max.DatasEntity.ClassListEntity> class_list;
public MyAdpater(Context context) {
this.context = context;
initData();
}
private void initData() {
OkHttp3Utils.doGet("http://169.254.168.158/mobile/index.php?act=goods_class&op=get_child_all&gc_id=1", new OnUiCallback() {
//http://169.254.168.158/mobile/index.php?act=goods_class&op=get_child_all&gc_id=1是自己服务器的id
@Override
public void onFailed(Call call, IOException e) {
}
@Override
public void onSuccess(String result) throws IOException {
Gson gson = new Gson();
Max bean2 = gson.fromJson(result, Max.class);
class_list = bean2.getDatas().getClass_list();
group = new String[class_list.size()];
child = new String[class_list.size()][];
groupHashMap = new HashMap<>();
childList = new ArrayList<>();
dataList = new ArrayList<>();
for (int i = 0; i < class_list.size(); i++) {
group[i] = class_list.get(i).getGc_name();
groupHashMap.put(i, false);
String[] strings = new String[class_list.get(i).getChild().size()];
HashMap<Integer, Boolean> map = new HashMap<>();
ArrayList<Bean> been = new ArrayList<>();
for (int y = 0; y <class_list.get(i).getChild().size(); y++) {
strings[y] =class_list.get(i).getGc_name() + class_list.get(i).getChild().get(y).getGc_name();
map.put(y, false);
Bean bean = new Bean("100", "1");
been.add(bean);
}
child[i] = strings;
childList.add(map);
dataList.add(been);
}
}
});
}
@Override
public int getGroupCount() {
return group==null?0:group.length;
}
@Override
public int getChildrenCount(int groupPosition) {
return child[groupPosition].length;
}
@Override
public Object getGroup(int groupPosition) {
return group[groupPosition];
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return child[childPosition];
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
GroupViewHolder holder = null;
if (convertView == null) {
convertView = View.inflate(context, R.layout.group_item, null);
holder = new GroupViewHolder();
holder.tv = (TextView) convertView.findViewById(R.id.group_tv);
holder.ck = (CheckBox) convertView.findViewById(R.id.group_ck);
convertView.setTag(holder);
} else {
holder = (GroupViewHolder) convertView.getTag();
}
holder.tv.setText(group[groupPosition]);
holder.ck.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
groupHashMap.put(groupPosition, !groupHashMap.get(groupPosition));
//设置二级列表的选中状态,根据一级列表的状态来改变
setChildCheckAll();
//计算选中的价格和数量
String shopPrice = getShopPrice();
//判断商品是否全部选中
boolean b = selectAll();
adapterData.Data(v, shopPrice, b);
}
});
holder.ck.setChecked(groupHashMap.get(groupPosition));
return convertView;
}
@Override
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
ChildViewHolder holder = null;
if (convertView == null) {
convertView = View.inflate(context, R.layout.child_item, null);
holder = new ChildViewHolder();
holder.tv = (TextView) convertView.findViewById(R.id.child_tv);
holder.ck = (CheckBox) convertView.findViewById(R.id.child_ck);
holder.jianshao = (TextView) convertView.findViewById(R.id.jianshao);
holder.zengjia = (TextView) convertView.findViewById(R.id.zengjia);
holder.number = (TextView) convertView.findViewById(R.id.number);
convertView.setTag(holder);
} else {
holder = (ChildViewHolder) convertView.getTag();
}
holder.tv.setText(child[groupPosition][childPosition]);
holder.ck.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HashMap<Integer, Boolean> hashMap = childList.get(groupPosition);
hashMap.put(childPosition, !hashMap.get(childPosition));
//判断二级列表是否全部选中
ChildisChecked(groupPosition);
//计算选中的价格和数量
String shopPrice = getShopPrice();
//判断商品是否全部选中
boolean b = selectAll();
adapterData.Data(v, shopPrice, b);
}
});
final ChildViewHolder finalHolder = holder;
holder.zengjia.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<Bean> been = dataList.get(groupPosition);
String num = finalHolder.number.getText().toString();
int i = Integer.parseInt(num);
++i;
been.get(childPosition).setNumber(i + "");
//计算选中的价格和数量
String shopPrice = getShopPrice();
//判断商品是否全部选中
boolean b = selectAll();
adapterData.Data(v, shopPrice, b);
notifyDataSetChanged();
}
});
holder.jianshao.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<Bean> been = dataList.get(groupPosition);
String num = finalHolder.number.getText().toString();
int i = Integer.parseInt(num);
if (i > 1) {
--i;
}
been.get(childPosition).setNumber(i + "");
//计算选中的价格和数量
String shopPrice = getShopPrice();
//判断商品是否全部选中
boolean b = selectAll();
adapterData.Data(v, shopPrice, b);
notifyDataSetChanged();
}
});
holder.number.setText(dataList.get(groupPosition).get(childPosition).getNumber().toString());
holder.ck.setChecked(childList.get(groupPosition).get(childPosition));
return convertView;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
}
class GroupViewHolder {
TextView tv;
CheckBox ck;
}
class ChildViewHolder {
TextView tv;
CheckBox ck;
TextView jianshao;
TextView zengjia;
TextView number;
}
//设置二级列表的选中状态,根据一级列表的状态来改变
private void setChildCheckAll() {
for (int i = 0; i < childList.size(); i++) {
HashMap<Integer, Boolean> integerBooleanHashMap1 = childList.get(i);
Set<Map.Entry<Integer, Boolean>> entries = integerBooleanHashMap1.entrySet();
for (Map.Entry<Integer, Boolean> entry : entries) {
entry.setValue(groupHashMap.get(i));
}
}
notifyDataSetChanged();
}
//判断二级列表是否全部选中
private void ChildisChecked(int groupPosition) {
boolean ischecked = true;
HashMap<Integer, Boolean> hashMap = childList.get(groupPosition);
Set<Map.Entry<Integer, Boolean>> entries = hashMap.entrySet();
for (Map.Entry<Integer, Boolean> entry : entries) {
if (!entry.getValue()) {
ischecked = false;
break;
}
}
groupHashMap.put(groupPosition, ischecked);
notifyDataSetChanged();
}
//全选
public void checkAllShop(boolean checked) {
Set<Map.Entry<Integer, Boolean>> entries = groupHashMap.entrySet();
for (Map.Entry<Integer, Boolean> entry : entries) {
entry.setValue(checked);
}
//调用让二级列表全选的方法
setChildCheckAll();
notifyDataSetChanged();
}
//计算价格
public String getShopPrice() {
int price = 0;
int number = 0;
for (int y = 0; y < childList.size(); y++) {
HashMap<Integer, Boolean> integerBooleanHashMap1 = childList.get(y);
Set<Map.Entry<Integer, Boolean>> entries = integerBooleanHashMap1.entrySet();
for (Map.Entry<Integer, Boolean> entry : entries) {
if (entry.getValue()) {
Bean bean = dataList.get(y).get(entry.getKey());
price += Integer.parseInt(bean.getPrice()) * Integer.parseInt(bean.getNumber());
number += Integer.parseInt(bean.getNumber());
}
}
}
return price + "," + number;
}
//编辑一级和二级列表,如果全部选中,全选按钮也选中
public boolean selectAll() {
boolean isChecked = true;
if(childList!=null){
for (int y = 0; y < childList.size(); y++) {
HashMap<Integer, Boolean> hashMap = childList.get(y);
Set<Map.Entry<Integer, Boolean>> entries = hashMap.entrySet();
for (Map.Entry<Integer, Boolean> entry : entries) {
if (!entry.getValue()) {
isChecked = false;
break;
}
}
}
}
return isChecked;
}
private AdapterData adapterData;
public interface AdapterData {
void Data(View v, String str, boolean b);
}
public void getAdapterData(AdapterData adapterData) {
this.adapterData = adapterData;
}
}
group_item一级列表的布局
<?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">
<CheckBox
android:id="@+id/group_ck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:focusable="false" />
<TextView
android:id="@+id/group_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
child-item二级列表的布局
<?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:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/child_ck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp" />
<TextView
android:id="@+id/child_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/danjia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:text="100元"
android:textColor="#ff0000" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<TextView
android:id="@+id/jianshao"
android:layout_width="20dp"
android:layout_height="30dp"
android:gravity="center"
android:text="-"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/number"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text="1"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/zengjia"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_marginRight="20dp"
android:gravity="center"
android:text="+"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
一级列表的Bean
public class Bean {
private String price;
private String number;
public Bean(String price, String number) {
this.price = price;
this.number = number;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
}
二级列表的网络解析的数据Bean
package com.example.mycar.Beans;
import java.util.List;
/10/24.
*/
public class Max {
/**
* code : 200
* datas : {"class_list":[{"gc_id":"4","gc_name":"女装","child":[{"gc_id":"12","gc_name":"T恤"},{"gc_id":"13","gc_name":"衬衫"},{"gc_id":"14","gc_name":"针织衫"},{"gc_id":"15","gc_name":"雪纺衫"},{"gc_id":"16","gc_name":"卫衣"},{"gc_id":"17","gc_name":"马甲"},{"gc_id":"18","gc_name":"连衣裙"},{"gc_id":"19","gc_name":"半身裙"},{"gc_id":"20","gc_name":"牛仔裤"},{"gc_id":"21","gc_name":"休闲裤"},{"gc_id":"22","gc_name":"打底裤"},{"gc_id":"23","gc_name":"正装裤"},{"gc_id":"24","gc_name":"西服"},{"gc_id":"25","gc_name":"短外套"},{"gc_id":"26","gc_name":"风衣"},{"gc_id":"27","gc_name":"大衣"},{"gc_id":"28","gc_name":"皮衣皮草"},{"gc_id":"29","gc_name":"棉服"},{"gc_id":"30","gc_name":"羽绒服"},{"gc_id":"31","gc_name":"孕妇装"},{"gc_id":"32","gc_name":"大码装"},{"gc_id":"33","gc_name":"中老年装"},{"gc_id":"34","gc_name":"婚纱礼服"},{"gc_id":"1053","gc_name":"女装"}]},{"gc_id":"5","gc_name":"男装","child":[{"gc_id":"35","gc_name":"衬衫"},{"gc_id":"36","gc_name":"T恤"},{"gc_id":"37","gc_name":"POLO衫"},{"gc_id":"38","gc_name":"针织衫"},{"gc_id":"39","gc_name":"羊绒衫"},{"gc_id":"40","gc_name":"卫衣"},{"gc_id":"41","gc_name":"马甲/背心"},{"gc_id":"42","gc_name":"夹克"},{"gc_id":"43","gc_name":"风衣"},{"gc_id":"44","gc_name":"大衣"},{"gc_id":"45","gc_name":"皮衣"},{"gc_id":"46","gc_name":"外套"},{"gc_id":"47","gc_name":"西服"},{"gc_id":"48","gc_name":"棉服"},{"gc_id":"49","gc_name":"羽绒服"},{"gc_id":"50","gc_name":"牛仔裤"},{"gc_id":"51","gc_name":"休闲裤"},{"gc_id":"52","gc_name":"西裤"},{"gc_id":"53","gc_name":"西服套装"},{"gc_id":"54","gc_name":"大码装"},{"gc_id":"55","gc_name":"中老年装"},{"gc_id":"56","gc_name":"唐装"},{"gc_id":"57","gc_name":"工装"}]},{"gc_id":"6","gc_name":"内衣","child":[{"gc_id":"58","gc_name":"文胸"},{"gc_id":"59","gc_name":"女式内裤"},{"gc_id":"60","gc_name":"男式内裤"},{"gc_id":"61","gc_name":"家居"},{"gc_id":"62","gc_name":"睡衣"},{"gc_id":"63","gc_name":"塑身衣"},{"gc_id":"64","gc_name":"睡袍/浴袍"},{"gc_id":"65","gc_name":"泳衣"},{"gc_id":"66","gc_name":"背心"},{"gc_id":"67","gc_name":"抹胸"},{"gc_id":"68","gc_name":"连裤袜"},{"gc_id":"69","gc_name":"美腿袜"},{"gc_id":"70","gc_name":"男袜"},{"gc_id":"71","gc_name":"女袜"},{"gc_id":"72","gc_name":"情趣内衣"},{"gc_id":"73","gc_name":"保暖内衣"}]},{"gc_id":"7","gc_name":"运动","child":[{"gc_id":"74","gc_name":"休闲鞋"},{"gc_id":"75","gc_name":"帆布鞋"},{"gc_id":"76","gc_name":"跑步鞋"},{"gc_id":"77","gc_name":"篮球鞋"},{"gc_id":"78","gc_name":"足球鞋"},{"gc_id":"79","gc_name":"训练鞋"},{"gc_id":"80","gc_name":"乒羽鞋"},{"gc_id":"81","gc_name":"拖鞋"},{"gc_id":"82","gc_name":"卫衣"},{"gc_id":"83","gc_name":"夹克"},{"gc_id":"84","gc_name":"T恤"},{"gc_id":"85","gc_name":"棉服/羽绒服"},{"gc_id":"86","gc_name":"运动裤"},{"gc_id":"87","gc_name":"套装"},{"gc_id":"88","gc_name":"运动包"},{"gc_id":"89","gc_name":"运动配件"}]},{"gc_id":"8","gc_name":"女鞋","child":[{"gc_id":"90","gc_name":"平底鞋"},{"gc_id":"91","gc_name":"高跟鞋"},{"gc_id":"92","gc_name":"单鞋"},{"gc_id":"93","gc_name":"休闲鞋"},{"gc_id":"94","gc_name":"凉鞋"},{"gc_id":"95","gc_name":"女靴"},{"gc_id":"96","gc_name":"雪地靴"},{"gc_id":"97","gc_name":"拖鞋"},{"gc_id":"98","gc_name":"裸靴"},{"gc_id":"99","gc_name":"筒靴"},{"gc_id":"100","gc_name":"帆布鞋"},{"gc_id":"101","gc_name":"雨鞋/雨靴"},{"gc_id":"102","gc_name":"妈妈鞋"},{"gc_id":"103","gc_name":"鞋配件"},{"gc_id":"104","gc_name":"特色鞋"},{"gc_id":"105","gc_name":"鱼嘴鞋"},{"gc_id":"106","gc_name":"布鞋/绣花鞋"}]},{"gc_id":"9","gc_name":"男鞋","child":[{"gc_id":"107","gc_name":"商务休闲鞋"},{"gc_id":"108","gc_name":"正装鞋"},{"gc_id":"109","gc_name":"休闲鞋"},{"gc_id":"110","gc_name":"凉鞋/沙滩鞋"},{"gc_id":"111","gc_name":"男靴"},{"gc_id":"112","gc_name":"功能鞋"},{"gc_id":"113","gc_name":"拖鞋"},{"gc_id":"114","gc_name":"传统布鞋"},{"gc_id":"115","gc_name":"鞋配件"},{"gc_id":"116","gc_name":"帆布鞋"},{"gc_id":"117","gc_name":"豆豆鞋"},{"gc_id":"118","gc_name":"驾车鞋"}]},{"gc_id":"10","gc_name":"配饰","child":[{"gc_id":"119","gc_name":"太阳镜"},{"gc_id":"120","gc_name":"框镜"},{"gc_id":"121","gc_name":"皮带"},{"gc_id":"122","gc_name":"围巾"},{"gc_id":"123","gc_name":"手套"},{"gc_id":"124","gc_name":"帽子"},{"gc_id":"125","gc_name":"领带"},{"gc_id":"126","gc_name":"袖扣"},{"gc_id":"127","gc_name":"其他配件"},{"gc_id":"128","gc_name":"丝巾"},{"gc_id":"129","gc_name":"披肩"},{"gc_id":"130","gc_name":"腰带"},{"gc_id":"131","gc_name":"腰链/腰封"},{"gc_id":"132","gc_name":"棒球帽"},{"gc_id":"133","gc_name":"毛线"},{"gc_id":"134","gc_name":"遮阳帽"},{"gc_id":"135","gc_name":"防紫外线手套"},{"gc_id":"136","gc_name":"草帽"}]},{"gc_id":"11","gc_name":"童装","child":[{"gc_id":"137","gc_name":"套装"},{"gc_id":"138","gc_name":"上衣"},{"gc_id":"139","gc_name":"裤子"},{"gc_id":"140","gc_name":"裙子"},{"gc_id":"141","gc_name":"内衣/家居服"},{"gc_id":"142","gc_name":"羽绒服/棉服"},{"gc_id":"143","gc_name":"亲子装"},{"gc_id":"144","gc_name":"儿童配饰"},{"gc_id":"145","gc_name":"礼服/演出服"},{"gc_id":"146","gc_name":"运动鞋"},{"gc_id":"147","gc_name":"单鞋"},{"gc_id":"148","gc_name":"靴子"},{"gc_id":"149","gc_name":"凉鞋"},{"gc_id":"150","gc_name":"功能鞋"}]}]}
*/
private int code;
private DatasEntity datas;
public void setCode(int code) {
this.code = code;
}
public void setDatas(DatasEntity datas) {
this.datas = datas;
}
public int getCode() {
return code;
}
public DatasEntity getDatas() {
return datas;
}
public static class DatasEntity {
/**
* gc_id : 4
* gc_name : 女装
* child : [{"gc_id":"12","gc_name":"T恤"},{"gc_id":"13","gc_name":"衬衫"},{"gc_id":"14","gc_name":"针织衫"},{"gc_id":"15","gc_name":"雪纺衫"},{"gc_id":"16","gc_name":"卫衣"},{"gc_id":"17","gc_name":"马甲"},{"gc_id":"18","gc_name":"连衣裙"},{"gc_id":"19","gc_name":"半身裙"},{"gc_id":"20","gc_name":"牛仔裤"},{"gc_id":"21","gc_name":"休闲裤"},{"gc_id":"22","gc_name":"打底裤"},{"gc_id":"23","gc_name":"正装裤"},{"gc_id":"24","gc_name":"西服"},{"gc_id":"25","gc_name":"短外套"},{"gc_id":"26","gc_name":"风衣"},{"gc_id":"27","gc_name":"大衣"},{"gc_id":"28","gc_name":"皮衣皮草"},{"gc_id":"29","gc_name":"棉服"},{"gc_id":"30","gc_name":"羽绒服"},{"gc_id":"31","gc_name":"孕妇装"},{"gc_id":"32","gc_name":"大码装"},{"gc_id":"33","gc_name":"中老年装"},{"gc_id":"34","gc_name":"婚纱礼服"},{"gc_id":"1053","gc_name":"女装"}]
*/
private List<ClassListEntity> class_list;
public void setClass_list(List<ClassListEntity> class_list) {
this.class_list = class_list;
}
public List<ClassListEntity> getClass_list() {
return class_list;
}
public static class ClassListEntity {
private String gc_id;
private String gc_name;
/**
* gc_id : 12
* gc_name : T恤
*/
private List<ChildEntity> child;
public void setGc_id(String gc_id) {
this.gc_id = gc_id;
}
public void setGc_name(String gc_name) {
this.gc_name = gc_name;
}
public void setChild(List<ChildEntity> child) {
this.child = child;
}
public String getGc_id() {
return gc_id;
}
public String getGc_name() {
return gc_name;
}
public List<ChildEntity> getChild() {
return child;
}
public static class ChildEntity {
private String gc_id;
private String gc_name;
public void setGc_id(String gc_id) {
this.gc_id = gc_id;
}
public void setGc_name(String gc_name) {
this.gc_name = gc_name;
}
public String getGc_id() {
return gc_id;
}
public String getGc_name() {
return gc_name;
}
}
}
}
}
最终效果图