Dynamically changing ListView elements
<p>I'm using a Listview to display three columns of information from a Cursor in two TextViews on the screen. The left TextView is static while the right one has translations in two languages that toggle when selected.</p>

<p>My problem is that this works fine until I scroll the ListView, at which point the adapter and the ListView seem to become unsynchronized, leading to flaky behavior and finally a null pointer exception.</p>

<p>Here's the onListItemClick code:</p>

<pre><code> public void onListItemClick(ListView l, View v, int position, long id){
    //first revert previous selection to English
    if(previous_position!=99){
      View vo =l.getChildAt(previous_position);
      TextView pt = (TextView)vo.findViewById(R.id.english);
      pt.setTextColor(Color.BLUE);
      pt.setText(previous_text);
    }

    //now show current selection in Hindi
    TextView t = (TextView) v.findViewById(R.id.translation);
    t.setTextColor(Color.RED);
    t.setText(gloCursor.getString(3));

    //finally remember where we changed things so we can revert them
    previous_position = position;
    previous_text = gloCursor.getString(3);

    // adapter data notification
    //adapter.notifyDataSetChanged();
    }
</code></pre>

<p>I've commented out notifyDataStateChanged as it hasn't worked for me in this case. </p>

<p>Would appreciate any insight or maybe a better design for this.</p>

<p>thanks,
P.</p>
