• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps problem in Custom Listview click event handling

manvinder

Newbie
Hi all,

I am using Custom listview in my application. Each Row of custom List contains checkbox and 2 TextView. I am able to populate data using CustomAdapter class which extends ArrayAdapter<MyContact>.

The problem I am facing is that I am not able to handle click event on List Row i.e. I am not able to listen which row is clicked on the listview for further action. Help me...

here is the code I am using for CustomAdapter class..

class CustomAdapter extends ArrayAdapter<MyContact> {

private final int resource;

public CustomAdapter(Context context, int resource, ArrayList<MyContact> objects) {
super(context, resource, objects);
this.resource = resource;
}

@Override
public int getCount() {
return allContactsList.size();
}

@Override
public MyContact getItem(int position) {
return allContactsList.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

if(convertView == null) {
convertView = View.inflate(getContext(), resource, null);
}

MyContact buddy = getItem(position);
if(buddy != null) {
TextView buddyName = (TextView) convertView.findViewById(R.id.buddyName);
//TextView buddyEmailId = (TextView) v.findViewById(R.id.buddyEmail);
TextView buddyDob = (TextView) convertView.findViewById(R.id.buddyDob);
CheckBox isSelected = (CheckBox) convertView.findViewById(R.id.isSelected);

buddyName.setText(buddy.getName());
//buddyEmailId.setText(buddy.getEmail());
buddyDob.setText(buddy.getDob());
isSelected.setTag(buddy.getEmail());
}
return convertView;
}

}
 
Back
Top Bottom