tags:

views:

108

answers:

1

Hi,

I create a CursorAdapter to provide data for my ListView.

I implement the bindView() method to show data in a row of my Listview. But at the end of my bindView, I add an clickListener to it. But when I run it on emulator, I don't see any print statement.

Can you please tell me how to add event handling in a row in ListView?

view.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            System.out.println (" getting an onclick event....");
     }
});
+1  A: 

You could attach OnItemClickListener to the ListView - not the rows individually.

listView.setOnItemClickListener( new OnItemClickListener() {
    public void onItemClick(AdapterView<?> arg0, View view, int arg2, long arg3) {
        Log.d("TAG", "Clicked");
    }
});
Mads Kristiansen