private ExpandableListView elv;
private CheckBox all;
private TextView all_count;
private TextView all_money;
private List<GroupBean> flist;
private List<List<ChildBean>> clist;
private String url = "http://120.27.23.105/product/searchProducts?keywords=%E7%AC%94%E8%AE%B0%E6%9C%AC&page=1";
private List<ShopBean> list;
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
String json = (String) msg.obj;
Gson gson = new Gson();
ShopBean bean = gson.fromJson(json , ShopBean.class);
List<ShopBean.DataBean> data = bean.getData();
for (int i=0;i<data.size();i++){
flist.add(new GroupBean(data.get(i).getTitle(),false));
List<ChildBean> slist=new ArrayList<>();
for (int j=0;j<flist.size();j++){
slist.add(new ChildBean(data.get(j).getTitle(),data.get(j).getPrice()+"",data.get(j).getImages(),false,1));
}
clist.add(slist);
}
CartUtils.setCartData(MainActivity.this,flist,clist,elv,all,all_count,all_money);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
elv = (ExpandableListView) findViewById(R.id.elv);
all=(CheckBox)findViewById(R.id.all);
all_count=(TextView)findViewById(R.id.all_count);
all_money=(TextView)findViewById(R.id.all_money);
//数据
setData();
}
private void setData() {
flist=new ArrayList<>();
clist=new ArrayList<>();
OkHttp3Utils.doGet(url, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String s = response.body().string();
Log.i("dfd" ,s.toString());
Message message=new Message();
message.obj=s;
handler.sendMessage(message);
}
});
}
private CheckBox all;
private TextView all_count;
private TextView all_money;
private List<GroupBean> flist;
private List<List<ChildBean>> clist;
private String url = "http://120.27.23.105/product/searchProducts?keywords=%E7%AC%94%E8%AE%B0%E6%9C%AC&page=1";
private List<ShopBean> list;
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
String json = (String) msg.obj;
Gson gson = new Gson();
ShopBean bean = gson.fromJson(json , ShopBean.class);
List<ShopBean.DataBean> data = bean.getData();
for (int i=0;i<data.size();i++){
flist.add(new GroupBean(data.get(i).getTitle(),false));
List<ChildBean> slist=new ArrayList<>();
for (int j=0;j<flist.size();j++){
slist.add(new ChildBean(data.get(j).getTitle(),data.get(j).getPrice()+"",data.get(j).getImages(),false,1));
}
clist.add(slist);
}
CartUtils.setCartData(MainActivity.this,flist,clist,elv,all,all_count,all_money);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
elv = (ExpandableListView) findViewById(R.id.elv);
all=(CheckBox)findViewById(R.id.all);
all_count=(TextView)findViewById(R.id.all_count);
all_money=(TextView)findViewById(R.id.all_money);
//数据
setData();
}
private void setData() {
flist=new ArrayList<>();
clist=new ArrayList<>();
OkHttp3Utils.doGet(url, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String s = response.body().string();
Log.i("dfd" ,s.toString());
Message message=new Message();
message.obj=s;
handler.sendMessage(message);
}
});
}