void SetProduct(Bundle bundle) { totalSale += bundle.getFloat("price"); lblTotal.setText( getString(R.string.currency_symbol) + Functions.GetFloatValueWithTwoDecimals(totalSale)); Product product = new Product(bundle.getInt("id"), bundle.getString("name")); product.setPrice(bundle.getFloat("price")); if (productAdapter == null) { ArrayList<Product> products = new ArrayList<Product>(); productAdapter = new ProductAdapter(this, products); ListView lstProducts = (ListView) findViewById(R.id.lstProductList); lstProducts.setAdapter(productAdapter); } productAdapter.add(product); productAdapter.notifyDataSetChanged(); }
void Events() { StartActivity((Button) findViewById(R.id.btnAddCustomer), CustomerListGUI.class); StartActivity((Button) findViewById(R.id.btnAddProduct), ProductListGUI.class); final Button btnSaveSale = (Button) findViewById(R.id.btnSaveSale); btnSaveSale.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { SaveSale(); } }); final ListView lstProducts = (ListView) findViewById(R.id.lstProductList); lstProducts.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { AskForDeleteProduct(position); } }); }