title: Getting textView values from listView
body: <p>I have a <code>listView</code> that gets filled by a <code>simpleCursorAdapter</code> from a <code>sqlite</code> database.
  Every <code>listView</code> entry has 3 <code>textViews</code>  : Value,hour and date.</p>
  
  <p>I filter the <code>listView cursor</code> by the date value so if i enter <code>24-07-2013</code> in the filter it will only show the entries from the sqlite database that have the date set to that.It will sometimes show 1 or 3 or any number,depending on how many entries are in the database.</p>
  
  <p>What i want to do is to add all the <code>Values</code> into a total and show it in a separate <code>TextView</code> or something.</p>
  
  <p>So my question is : how do i get the <code>Values</code> from the <code>listView</code> and add them up ?</p>
  
  <p>Here's my code,i'll try not to copy it all.</p>
  
  <pre><code>private void displayListView() {
  
      Cursor cursor = dbHelper.fetchAllCountries();
  
      // The desired columns to be bound
      String[] columns = new String[] {
              SQLiteT.DB_COLUMN_1_NAME3,
              SQLiteT.DB_COLUMN_2_NAME3,
              SQLiteT.DB_COLUMN_3_NAME3,
  
      };
  
      int[] to = new int[] {
  
      R.id.numeprod3,
      R.id.cantotala3, 
      R.id.ultimulpret3,
  
      };
  
      dataAdapter = new SimpleCursorAdapter(this, R.layout.country_info3,
              cursor, columns, to, 0);
  
  
      ListView listView = (ListView) findViewById(R.id.listView13);
      // Assign adapter to ListView
      listView.setAdapter(dataAdapter);
  
  myFilter = (EditText) findViewById(R.id.myFilter3);
      myFilter.addTextChangedListener(new TextWatcher() {
  
          public void afterTextChanged(Editable s) {
          }
  
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
          }
  
          public void onTextChanged(CharSequence s, int start, int before,
                  int count) {
              dataAdapter.getFilter().filter(s.toString());
          }
      });
  
      dataAdapter.setFilterQueryProvider(new FilterQueryProvider() {
          public Cursor runQuery(CharSequence constraint) {
              return dbHelper.fetchCountriesByName(constraint.toString());
  </code></pre>
  
  <p>And this is how i extract data from the database :</p>
  
  <pre><code> public Cursor fetchCountriesByName(String inputText) throws SQLException {
      Cursor mCursor = null;
      if (inputText == null || inputText.length() == 0) {
          mCursor = this.sqliteDBInstance3.query(DB_TABLE_NAME3, new String[] {KEY_ROWID,
                  DB_COLUMN_1_NAME3, DB_COLUMN_2_NAME3, DB_COLUMN_3_NAME3
                  }, null, null, null, null, null);
  
      } else {
          mCursor = this.sqliteDBInstance3.query(true, DB_TABLE_NAME3,
                  new String[] {KEY_ROWID, DB_COLUMN_1_NAME3,
                          DB_COLUMN_2_NAME3, DB_COLUMN_3_NAME3 },
                  DB_COLUMN_3_NAME3 + " like '%" + inputText + "%'", null,
                  null, null, null, null);
      }
      if (mCursor != null) {
          mCursor.moveToFirst();
      }
      return mCursor;
  
  }
  
  public Cursor fetchAllCountries() {
  
      Cursor mCursor = this.sqliteDBInstance3.query(DB_TABLE_NAME3,
              new String[] {KEY_ROWID, DB_COLUMN_1_NAME3, DB_COLUMN_2_NAME3,
                      DB_COLUMN_3_NAME3 }, null, null, null, null,
              null);
  
      if (mCursor != null) {
          mCursor.moveToFirst();
      }
      return mCursor;
  }
  </code></pre>
  
  <p>UPDATE :</p>
  
  <p>I ended up doing this.It isn't the nicest solution i think but it does the job.</p>
  
  <pre><code>//Added to this :
  public void onTextChanged(CharSequence s, int start, int before,
                  int count) {
              dataAdapter.getFilter().filter(s.toString());
              totaluri= dbHelper.getAllCountries(s.toString());
              //ore=dbHelper.getAllCountries2(s.toString());
              int pff=totaluri.length;
              float totalulma = 0;
              for(int i=0;i&lt;pff;i++){totalulma=totalulma+Float.parseFloat(totaluri[i]);}
              totaltotaluri.setText(String.format("Total: %.2f", totalulma));
  
  //And created this method inside my database activity 
  public String[] getAllCountries(String inputText) {
      Cursor cursor = this.sqliteDBInstance3.query(DB_TABLE_NAME3,
              new String[] { DB_COLUMN_1_NAME3 }, DB_COLUMN_3_NAME3 + " like '%" + inputText + "%'", null, null, null,
              null);
  
      if (cursor.getCount() &gt; 0) {
          String[] str = new String[cursor.getCount()];
          int i = 0;
  
          while (cursor.moveToNext()) {
              str[i] = cursor.getString(cursor
                      .getColumnIndex(DB_COLUMN_1_NAME3));
              i++;
          }
          return str;
      } else {
          return new String[] {};
      }
  }
  </code></pre>
  
  <p>So,when the input in the filter edittext gets changed,it runs another query in the database.If there's a better,more efficient way to do this please tell me...i really want to learn and of course,i don't want to make my app use too many resources.</p>