I'm 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 = $ 15.00
NumberPicker 2 = qnt 2 = $ 10.00
NumberPicker 3 = qnt 4 = $ 8.00
The total of each item is dynamic, so it changes the quantity already shows the total value in front.
I am stuck in the grand total. This grand total would pick up all the totals and add up and return a dynamic overall total.
Numberpickers listeners below
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 total textview. But if user decreases the amount it still keeps adding up.