title: Calculate total sum from all prices items
body: <p>I have a <code>ListView</code> with 3 <code>TextViews</code> columns where I can click one of them and appear a <code>DialogAlert</code> and choose quantity. </p>
  
  <p>When choose quantity from <code>AlertDialog</code> my price for specific product is multiply with number quantity.</p>
  
  <p>Now, problem is I want in my <code>ListVIew</code> to make a <code>Total</code> for all products, I can't figure it out how to <strong>calculate total</strong> for products when quantity is changed. </p>
  
  <p><strong><code>My adapter :</code></strong> </p>
  
  <pre><code>public class VanzatorProduseList extends ArrayAdapter&lt;VanzatorProduse&gt; {
  
      private Activity context;
      private List&lt;VanzatorProduse&gt; vanzatorProduseList;
      private double total = 0.0;
  
  
      public VanzatorProduseList(Activity context, List&lt;VanzatorProduse&gt; vanzatorProduseList) {
          super(context, R.layout.list_produse_vanzator, vanzatorProduseList);
          this.context = context;
          this.vanzatorProduseList = vanzatorProduseList;
      }
  
      @NonNull
      @Override
      public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
          LayoutInflater inflater = context.getLayoutInflater();
          View listViewItem = inflater.inflate(R.layout.list_produse_vanzator, null, true);
          final TextView textViewProdus1 = (TextView) listViewItem.findViewById(R.id.textViewProdus1);
          final TextView textViewPret1 = (TextView) listViewItem.findViewById(R.id.textViewPret1);
          final TextView textViewCantitate1 = (TextView) listViewItem.findViewById(R.id.textViewCantitate1);
          final VanzatorProduse vanzatorProduse = vanzatorProduseList.get(position);
          textViewProdus1.setText(vanzatorProduse.getProdus());
          textViewPret1.setText(vanzatorProduse.getPret());
          textViewCantitate1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
                  LayoutInflater inflater = context.getLayoutInflater();
                  final View dialogView = inflater.inflate(R.layout.dialog_alert, null);
                  dialogBuilder.setView(dialogView);
                  final ElegantNumberButton elegantNumberButton = (ElegantNumberButton) dialogView.findViewById(R.id.elegantNumberButton);
                  final Button dialog_btn = (Button) dialogView.findViewById(R.id.dialog_btn);
                  dialogBuilder.setTitle("Alege cantitate : " + vanzatorProduse.getProdus());
                  final AlertDialog b = dialogBuilder.create();
                  b.show();
                  dialog_btn.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          String num = elegantNumberButton.getNumber();
                          total = (Integer.parseInt(vanzatorProduse.getPret()) * (Integer.parseInt(num)));
                          textViewPret1.setText(String.valueOf(total));
                          textViewCantitate1.setText(num);
                          b.dismiss();
                      }
                  });
              }
          });
          return listViewItem;
      }
  }
  </code></pre>
  
  <p>Hope you can understand my question, I really have some serious problem with this problem and even if I looked for lots of tutorials, nothing happened. </p>