/** 清空我的菜单数据 */ public void clearElecartList() { dbhelper.deleteAllData(DBHelper.ELE_CART_TM_NAME); Cursor ec = dbhelper.query(DBHelper.ELE_CART_TM_NAME); electrocartgoodslists = jmelecart.getElecarttoSQLite(ec); ec.close(); // 提示菜单清楚 String msg = "您的菜单已被删除"; Toast t = Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG); t.show(); }
/** 隐重新计算elecart内容 */ public void calnewElecartListView() { electrocartgoodslists.clear(); // 读取ele_cart缓存 Cursor ec = dbhelper.query(DBHelper.ELE_CART_TM_NAME); electrocartgoodslists = jmelecart.getElecarttoSQLite(ec); ec.close(); Context mContext = YooxiCoffeeGoodsDetail.this; LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); final View alertCartlist = inflater.inflate(R.layout.yooxicafe_alertlist, null); listViewForCart = (ListView) alertCartlist.findViewById(R.id.yooxicartlistview); // 我的菜单listview listViewForCart.setAdapter( new JshopMyElecartListViewAdapter(electrocartgoodslists, this.getApplicationContext())); }
/** 读取我的菜单数据 */ public void setElecartListView() { electrocartgoodslists.clear(); // 读取ele_cart缓存 Cursor ec = dbhelper.query(DBHelper.ELE_CART_TM_NAME); electrocartgoodslists = jmelecart.getElecarttoSQLite(ec); ec.close(); /** 构建弹出框 */ AlertDialog.Builder builder; Context mContext = YooxiCoffeeGoodsDetail.this; LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); final View alertCartlist = inflater.inflate(R.layout.yooxicafe_alertlist, null); listViewForCart = (ListView) alertCartlist.findViewById(R.id.yooxicartlistview); // 我的菜单listview builder = new AlertDialog.Builder(mContext); listViewForCart.setAdapter( new JshopMyElecartListViewAdapter(electrocartgoodslists, this.getApplicationContext())); // 初始化控件 TextView confirm = (TextView) alertCartlist.findViewById(R.id.confirm); TextView clearall = (TextView) alertCartlist.findViewById(R.id.clearall); // 计算总价 total = 0.0; if (!electrocartgoodslists.isEmpty()) { for (int i = 0; i < electrocartgoodslists.size(); i++) { total = Arith.add( total, Arith.mul( Double.parseDouble(electrocartgoodslists.get(i).get("memberprice").toString()), Double.parseDouble( electrocartgoodslists.get(i).get("needquantity").toString()))); } TextView countmoney = (TextView) alertCartlist.findViewById(R.id.countmoney); countmoney.setText("¥" + total); } else { TextView countmoney = (TextView) alertCartlist.findViewById(R.id.countmoney); countmoney.setText("¥" + total); } builder.setTitle("已点清单").setView(alertCartlist); final AlertDialog alert = builder.create(); alert.show(); // confirm事件响应 confirm.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub alert.dismiss(); } }); // 清空菜单clearall clearall.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub clearList(); alert.dismiss(); } }); }