Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onClick(View view) {
- if (view.getId() == R.id.btnaceptar) {
- if (etinicio.getText().toString().isEmpty() || etarticulo.getText().toString().isEmpty() || etcantidad.getText().toString().isEmpty() ){
- Toast toast = Toast.makeText(this, "Ingresa una cantidad", Toast.LENGTH_SHORT);
- toast.show();
- }else{
- etinicio.setEnabled(false);
- etarticulo.setEnabled(false);
- etcantidad.setEnabled(false);
- btncomprar.setEnabled(false);
- }
- }
- if (view.getId() == R.id.btncomprar && etinicio.getText().toString().isEmpty() || etarticulo.getText().toString().isEmpty() || etcantidad.getText().toString().isEmpty()) {
- Toast toast = Toast.makeText(this, "Accion No permitida", Toast.LENGTH_SHORT);
- toast.show();
- }else{
- try{
- double inicio = Double.parseDouble(etinicio.getText().toString());
- double articulo = Double.parseDouble(etarticulo.getText().toString());
- double cantidad = Double.parseDouble(etcantidad.getText().toString());
- float total = (float) (articulo * cantidad);
- float total1 = (float) (inicio - total);
- float porciento = (float) ((total1 / inicio) * 100);
- String porcentaje = Float.toString(porciento);
- tvporcentaje.setText(porcentaje);
- float suma = (float) (inicio - total);
- String resultadosuma = String.valueOf(suma);
- tvdisponible.setText(resultadosuma);
- float suma2 = (float) (inicio - suma);
- String resultadosuma2 = String.valueOf(suma2);
- tvcompra.setText(resultadosuma2);
- ObjectAnimator anim = ObjectAnimator.ofInt(pbarra, "progress", 0, 100);
- anim.setDuration(2000);
- anim.setInterpolator(new DecelerateInterpolator());
- //iniciamos el progressbar
- anim.start();
- //Toast toast = Toast.makeText(this, "Favor de escribir Compras", Toast.LENGTH_SHORT);
- //toast.show();
- }catch (NumberFormatException e) {
- Toast toast = Toast.makeText(this, "Primero Acepta la Transaccion", Toast.LENGTH_SHORT);
- toast.show();
- }
- }
- if (view.getId() == R.id.btnceditar) {
- etinicio.setEnabled(true);
- etarticulo.setEnabled(true);
- etcantidad.setEnabled(true);
- }
- }
Add Comment
Please, Sign In to add comment