Android - CursorAdapter setViewValue not changing contents of TextView displayed text

53 views Asked by At

I have a simple cursor adapter with a ListView that works just fine. I output the Name to one of 3 TextViews in the ListView item XML.

But, based on user preference, I want to change the name from "Jeff Jones" to "Jones, Jeff".

I thought I could do this with overriding the SetViewValue() method.

Just a simple

public boolean setViewValue(View view, Cursor cursor, int i) {
    if (view.getId() == R.id.Name) {
        String Name = cursor.getString(cursor.getColumnIndex(nameColumn));
        Name = Name.substring(Name.lastIndexOf(" ") + 1) + ", " + Name.substring(0, Name.lastIndexOf(" "));
        ((TextView) view).setText(Name);
    }
}

If I step through this in the debugger, I am correctly building the "Last, First" string and setting the TextView value. But the text shows up as "First Last" in the ListView.

Where's my mistake?

1

There are 1 answers

0
JJJones_3860 On

I forgot to return true to indicate that the value has been overridden.

return true;