posted 12 years ago
It's a lot harder to explain *why* this is a problem, than to explain how to fix it. First, the fix: instead of "TextView t = (TextView) ..." use "final TextView t = (TextView) ".
The problem is that -without the "final"- the value of "t" could change, so it's not clear which object should be used when the OnClickListener is run. Putting the "final" there asserts that the value won't change, so a reference to that object can be stored safely for the OnClickListener to use.