0
I am using Numberpicker so that the user selects the quantity. Each numberpicker has a total that already appears on the screen according to the amount selected by the user.
Example: Numberpicker 1 = qnt 3 = R$ 15,00
Numberpicker 2 = qnt 2 = R$10,00
Numberpicker 3 = qnt 4 = R$8,00
The total of each item is dynamic, so change the quantity already shows the total value in front.
I am stuck in the overall total. That overall total would take all the totals and sum and return a dynamic overall total.
Below the listeners of Numberpickers
np_Garrafa.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker numberPicker, int i, int numEscolhido) {
qntGarrafa = numEscolhido;
total_Garrafa = qntGarrafa * 10;
txt_totalGarrafa.setText("R$ " + total_Garrafa);
Log.i("garrafa", String.valueOf(qntGarrafa));
}
});
np_Garrafao10.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker numberPicker, int i, int numEscolhido) {
qntGarrafao10 = numEscolhido;
total_Garrafao10 = qntGarrafao10 * 5;
txt_totalGarrafao10.setText("R$ " + total_Garrafao10);
Log.i("garrafa10", String.valueOf(qntGarrafao10));
}
});
np_Garrafao20.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker numberPicker, int i, int numEscolhido) {
qntGarrafao20 = numEscolhido;
total_Garrafao20 = qntGarrafao20 * 10;
txt_totalGarrafao20.setText("R$ " + total_Garrafao20);
Log.i("garrafa20", String.valueOf(qntGarrafao20));
}
});
I tried to put in each listener a variable that would receive the total of each item and display in the overall textview. But if user decrease the amount it still continues adding.
I used what you put and applied in another method. As soon as the user adds to the cart he makes the total sum and already displays, it became much more practical. Thank you
– Flávio