Android list activity
<p>OK, I have a list activity in my application.
I have tried to make it so that when a list item is selected to show the selection the background of the view should change. But now when I select one item, the item does get selected, but the background of random list items changes at the same time, but the selection is still correct.
Where am I making the mistake?</p>

<pre><code>protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    super.onListItemClick(l, v, position, id);

    Cursor c = (Cursor) mAdapter.getItem(position);
    String a = c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
    String b = c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));

    if (names != null)
    {
        if(numbers.contains(b))
        {
            names = names.replace(a+";", "");
            numbers = numbers.replace(b+";", "");
            v.setBackgroundResource(R.drawable.background);
        }
        else{
            names = names + a + ";";
            numbers = numbers + b + ";";
            v.setBackgroundResource(R.drawable.background_sel);
        }
    }
    else
    {
        names = a+";";
        numbers = b+";";
        v.setBackgroundResource(R.drawable.background_sel);
    }
}
</code></pre>
