Android: How to be notified when selection changes in single choice mode ListView?
<p>I want my ListView to highlight the selected item until selection changes.  Also, I want to be notified when selection changes.  </p>

<p>In order to accomplish the first task, I call <code>list.setChoiceMode(ListView.CHOICE_MODE_SINGLE)</code>.  </p>

<p>I'm not sure how to accomplish the second.  When a list item is clicked, my OnItemSelectedListener is never notified, and the OnItemClickListener is insufficient because by the time the OnItemClick event occurs, my ListView's checkedItem has been modified, so I cannot distinguish if the click event resulted in a selection change (it is possible/likely that the clicked item was already selected).</p>

<p>One option would be to store the currently checked index in a member variable, which I could use to determine if the click event corresponds to a selection change.  But this ugly and 
So, for this choice mode, certainly there is a way to do this with the provided listeners?</p>

<pre><code>public class Temp extends Activity implements OnItemClickListener, OnItemSelectedListener
{
    ListView mView;

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        List&lt;String&gt; strings = new ArrayList&lt;String&gt;();
        strings.add("1");
        strings.add("2");
        strings.add("3");
        strings.add("4");
        strings.add("5");


        mView = new ListView(this);
        mView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        mView.setAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_activated_1, strings));
        mView.setItemChecked(0, true);

        mView.setOnItemClickListener(this);
        mView.setOnItemSelectedListener(this);

        setContentView(mView);
    }

    @Override
    public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id)
    {
        //this never gets called
        Log.e("item selected", ""+position);
    }

    @Override
    public void onNothingSelected(AdapterView&lt;?&gt; parent)
    {
        Log.e("nothing seleted", "");
    }

    @Override
    public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id)
    {
                //by the time this occurs, position == mView.getCheckedItemPosition()
        Log.e("item clicked", ""+position);
    }
}
</code></pre>
