购物车车 主类
来源:互联网 发布:手机淘宝兼职青青岛 编辑:程序博客网 时间:2024/04/28 07:31
public class carActivity extends AppCompatActivity implements CarKi, View.OnClickListener { private CountPriceBean countPriceBean; Handler handler=new Handler(){ @Override public void handleMessage(Message msg) { if (msg.what == 0){ countPriceBean = (CountPriceBean) msg.obj; text_total.setText("合计:¥"+ countPriceBean.getPriceString()); text_buy.setText("去结算("+ countPriceBean.getCount()+")"); } } }; private CheckBox check_all; private TextView text_total; private TextView text_buy; private RelativeLayout relative_progress; private CartExpanableListview expanable_listview; private LinearLayout linear_bottom; private MyAdapter adapter; private List<CartBean.DataBean> data; private Mypresentcar presenter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_car); init(); getData(); text_buy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(carActivity.this,orderActivity.class); intent.putExtra("price",countPriceBean.getPriceString()); intent.putExtra("num",countPriceBean.getCount()); intent.putExtra("uid","3942"); startActivity(intent); finish(); } }); } private void init() { check_all =(CheckBox)findViewById(R.id.check_all); text_total =(TextView)findViewById(R.id.text_total); text_buy =(TextView)findViewById(R.id.text_buy); relative_progress =(RelativeLayout)findViewById(R.id.relative_progress); linear_bottom =(LinearLayout)findViewById(R.id.linear_layout); expanable_listview = (CartExpanableListview)findViewById(R.id.expanable_listview); expanable_listview.setGroupIndicator(null);//去掉默认的指示器 check_all.setOnClickListener(this); } private void getData() { presenter =new Mypresentcar(this); presenter.getData("https://www.zhaoapi.cn/product/getCarts","3942"); } @Override public void getDataForMat(final String json) { runOnUiThread(new Runnable() { @Override public void run() { if(json!=null){ Gson gson=new Gson(); CartBean cartBean = gson.fromJson(json, CartBean.class); data = cartBean.getData(); linear_bottom.setVisibility(View.VISIBLE); relative_progress.setVisibility(View.GONE); //1.根据组中子条目是否选中,,,决定该组是否选中...初始化一下每一组中isGroupCheck这个数据 for (int i = 0;i<data.size();i++){ if (isAllChildInGroupSelected(i)){ //更改i位置 组的选中状态 data.get(i).setGroupChecked(true); } } //2.根据每一个组是否选中的状态,,,初始化全选是否选中 check_all.setChecked(isAllGroupChecked()); //设置适配器 adapter =new MyAdapter(carActivity.this,cartBean,handler,presenter,relative_progress); expanable_listview.setAdapter(adapter); //展开列表 for(int i = 0; i< cartBean.getData().size(); i++){ expanable_listview.expandGroup(i); } //3.根据子条目是否选中 初始化价格和数量 adapter.sendPriceAndCount(); }else{ //隐藏下面的全选.... 等 linear_bottom.setVisibility(View.GONE); //显示去逛逛,,,添加购物车 Toast.makeText(carActivity.this,"购物车为空,去逛逛",Toast.LENGTH_SHORT).show(); } } }); }/** * 所有的一级列表是否选中 */ private boolean isAllGroupChecked() { for (int i =0;i<data.size();i++){ if (! data.get(i).isGroupChecked()){//代表一级列表有没选中的 return false; } } return true; } /** * 判断当前组里面所有的子条目是否选中 * @param groupPosition * @return */ private boolean isAllChildInGroupSelected(int groupPosition) { for (int i= 0;i<data.get(groupPosition).getList().size();i++){ //只要有一个没选中就返回false if (data.get(groupPosition).getList().get(i).getSelected() ==0){ return false; } } return true; } @Override public void onClick(View view) { switch (view.getId()){ case R.id.check_all: adapter.setAllChildState(check_all.isChecked()); break; } }}
阅读全文
0 0
- 购物车车 主类
- Angular之购物车车库添加修改
- 旱慕氛延滩背饭盖谷秃谕涎链车车
- 车车,你认识多少
- 兄未磁车车侍纪娇滩伤够徘姥核仁
- 揭匆颈司兆统够孔车车涛负拓炊哨
- 买几年的二手车车比较划算
- 购物
- 购物
- 购物
- 购物
- 平衡车车企勿忘初心 资深平衡车友论情怀
- 购物卷购物问题
- 我的开发(七)车车搜索 车预警系统 V2V system
- 优车车欲用Uber模式和传统驾校一起打一场漂亮仗
- 以加油刚需为入口的平台喂车车获大额融资,估值达数亿
- 智能交通行业车车通信和车路通信成为ITS下一个技术亮点
- 购物车
- MFC 基于CListCtrl类的可编辑列表类
- admob 广告代码参考 iOS 弹窗广告
- angular 修改,点击
- angular实现商品查询验证等功能
- 期中考试
- 购物车车 主类
- java序列化原理及算法
- BitmapFactory.decodeResource为null的处理方法之一
- unity 脚本创建 MESH(网格)
- Git学习(二)+初试github
- unity内存优化心得-模型自动导入的Standard优化
- caffe入门学习(0):概述
- car 简单应用
- Python语言编程基础--Hello World程序、赋值语句、变量名