lv.setOnClickListener(new OnClickListener(){
public void onClick(View v){
}
});
Does v
refer to the ListView
There is a setOnItemClickListener for what you want.
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()
I believe that v
refers to the whole ListView
. To add a click handler for an item, you want to use AdapterView.setOnItemClickListener.
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int arg2,long itemID) {
View itemView = view;
String fromDate = ((TextView)itemView.findViewById(R.id.fromDate)).getText().toString();
int position = (int) arg0.getSelectedItemId();
Log.d(TAG, "ListView Selected : "+fromDate+" Position:"+position+" arg2:"+arg2+" arg3:"+itemID);
}
});