teepusink teepusink - 3 months ago 8
Android Question

Android - ListView click HOWTO?

How do I listen to click event on a ListView?

This is what I have now

ListView list = (ListView)findViewById(R.id.ListView01);
...
list.setAdapter(adapter);


When I do the following

list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView parentView, View childView,
int position, long id)
{
setDetail(position);
}

public void onNothingSelected(AdapterView parentView) {

}
});


That doesn't seem to do anything on click.

And all those code live within a class that extends Activity.

Answer

On your list view, use setOnItemClickListener