I have a ListItem which includes an ImgaeView. I want to delete the ListItem whenever its image or icon is clicked. Here is my ListItemActivity. How would I call the remove method of the adapter to remove the ListItem? Im having the problem with referencing. Please let me know if there is any better way of doing it.
public class TaskListItem extends LinearLayout {
private Task task;
private TextView taskName;
private TextView responsible;
private TextView priority;
private ImageView bin;
protected TaskListAdapter adapter;
public TaskListItem(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
taskName = (TextView)findViewById(R.id.task_name);
responsible = (TextView)findViewById(R.id.responsible);
priority = (TextView)findViewById(R.id.priority);
bin = (ImageView)findViewById(R.id.remove_task);
}
public void setTask( final Task task) {
this.task = task;
taskName.setText(task.getName() + " ");
//Set responsibility text
responsible.setText("Resp: " + task.getReponsible());
//Set priority text
priority.setText(" Prio: " + task.getPiotiry());
/*
* onClickListener for image to delete
*/
bin.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
**call the adapters remove method to delete this item with parameter (this).**
}
});
}
public Task getTask() {
return task;
}
}