title: SimpleCursorAdapter and ViewBinder - Binding data to ListView items to be retrieved on click
body: <p>So I've got a <code>ListView</code> (using a <code>ListActivity</code>) that I'm populating from a <code>SQLiteDatabase</code>.  I'm trying to attach the ID (PK) of the row to the view, so that <code>onListItemClick</code> of each list item, I can do stuff with that ID.</p>
  
  <p>I've read that arbitrary data can be set to a <code>View</code> using <code>setTag</code> and retrieved with <code>getTag</code>(I haven't actually had this work successfully yet, so this may be the problem).  Here's a pared down version of what I'm using (for simplicity/brevity):</p>
  
  <pre><code>public class Favorites extends ListActivity {   
      public void onCreate(Bundle savedInstanceState){        
          super.onCreate(savedInstanceState);
          FavoritesDB db = FavoritesDB.getInstance(this);     
          Cursor c = db.fetchFavorites();
          startManagingCursor(c);     
          String[] columns = new String[] { "_id" };
          int[] to = new int[] { R.id.word };         
          SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.favorite, c, columns, to);     
          adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
              public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
                  view.setTag(cursor.getInt(0));
                  return true;
              }
          });
          setListAdapter(adapter);        
      }   
      @Override
      protected void onListItemClick(ListView l, View v, int position, long id) {
          Object wordID = v.getTag();
          Toast.makeText(getBaseContext(), "ID=" + wordID, 1).show();
      }       
  }
  </code></pre>
  
  <p>The <code>ListView</code> is being populated, and the <code>Toast</code> does show up, but it's always <code>"ID=null"</code>, so apparently the ID isn't being set in the <code>ViewBinder</code> call to <code>setTag</code>(or isn't being retrieved property with <code>getTag</code>).</p>