views:

548

answers:

3
    lv.setOnClickListener(new OnClickListener(){
        public void onClick(View v){

        }
    });

Does v refer to the ListView lv or the specific item selected in the list?

Thanks in advance.

+2  A: 

There is a setOnItemClickListener for what you want.

Nikola Smiljanić
+3  A: 

I believe that v refers to the whole ListView. To add a click handler for an item, you want to use AdapterView.setOnItemClickListener.

Erich Douglass
Perfect answer. Thank you
Tom R
A: 

onClickListener just listens to a click on the entire View. v will be the ListView.

What you probably want is onItemClickListener instead of onClickListener.

Or you may want to extend ListActivity and override onListItemClick()

mbaird