Modify data in a cursor

Last Updated:

  1. ralphtrent

    ralphtrent Well-Known Member

    Hi, I am new to android dev so please bare with me. I have been looking all day and found nothing that does what I want to do.
    I have data in a db and I need to manipulate its values when I display it.
    here is the code I have so far
    Code (Text):
    3. adapter = new SimpleCursorAdapter(this, R.layout.clock_item, c, FROM, TO);
    4. ListView lv = (ListView) findViewById(;
    5. lv.setAdapter(adapter);
    6. adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
    7.  @Override
    8.  public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
    9.  TextView tv = (TextView)view;
    10.  if(columnIndex == 0)
    11.  {
    12.   Log.i(TAG, "Current Text:" + tv.getText());
    13.   tv.setText("Hello");
    14.   Log.i(TAG, "Current Text:" + tv.getText());
    15.  }
    16. }
    When I look at the logCat for my tags I see this:
    Code (Text):
    2. Current Text:
    3. Current Text:Hello
    4. Current Text:test
    It looks like I am setting the text too early? AM I? On the screen test (which is the value from the db) still get displayed, but I want "Hello".
    Any help is appreciated.


Share This Page