title: How to Sum Value in ListView on Android Studio?
body: <p>I am trying JSON Parse in Android. I can parse values but I have a problem. For example, I use this <a href="https://jsoneditoronline.org/?id=ed2e2a394e2b449598f6d2a17557d8cc" rel="nofollow noreferrer">JSON</a>.  </p>
  
  <p>I made this function:</p>
  
  <pre><code> if (jsonStr != null) {
              try {
                  JSONObject jsonObj = new JSONObject(jsonStr);
  
                  JSONArray person = jsonObj.getJSONArray("person ");
  
                  for (int i = 0; i &lt; person .length(); i++) {
  
                      JSONObject c = person .getJSONObject(i);
                      String id = c.getString("id");
                      String name= c.getString("name");
                      String age= c.getString("age");
  
  
  
                      HashMap&lt;String, String&gt; persons = new HashMap&lt;&gt;();
  
                      persons .put("id", id);
                      persons .put("name", name);
                      persons .put("age", age);
  
                      personList.add(persons);
  </code></pre>
  
  <p>And use for display my screen:</p>
  
  <pre><code>  protected void onPostExecute(Void result) {
          super.onPostExecute(result);
          if (pDialog.isShowing())
              pDialog.dismiss();
  
          ListAdapter adapter = new SimpleAdapter(
                  Mainlayout.this, personList,
                  R.layout.person_list, new String[]{"name", "age"},
                  new int[]{
                  R.id.name,R.id.age});
  
          lv.setAdapter(adapter);
      }
  </code></pre>
  
  <p>I can see all data in my ListView but I want to sum the ages. I found <a href="https://stackoverflow.com/questions/36097776/sum-on-listview-item-in-android">this</a> on StackOverflow but I can't understand. How can I sum them?</p>