error funcion OnChange
Publicado por Alex (2 intervenciones) el 08/11/2019 05:58:16
EditText, la aplicacion se cierra con el mensaje de error que se cerró.
Aqui mi codigo:
Aqui mi codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public class crear extends AppCompatActivity {
EditText cantidad, precio, comision;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_crear);
cantidad = findViewById(R.id.cantidad);
precio = findViewById(R.id.precio);
comision = findViewById(R.id.comision);
cantidad.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
String cant = cantidad.getText().toString();
String price = precio.getText().toString();
int c = Integer.parseInt(cant);
int p = Integer.parseInt(price);
double com = c*p*0.958;
String cTotal = String.valueOf(com);
comision.setText(cTotal);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {}
});
}
}
Valora esta pregunta


0