Search code examples
androidonclickonitemclicklistenerandroid-adapterview

AdapterView.OnItemClickListener() not working


How to make AdapterView.OnItemClickListener() work, when

... activity implements View.OnLongClickListener, View.OnClickListener,
DragDropPresenter,
View.OnTouchListener { ... }

and I there is

public void onClick(View v) {
    // TODO Auto-generated method stub

}

to handle clicks? Idea is that drag and drop is activated on a long click, and the OnItemClickListener method is used on a short click. Is it even possible?


Solution

  • I overcame the problem of handling short clicks by assigning each cell a tag and then reading the tag with the simple onClick listener:

    public void onClick(View v) {
        Integer position = (Integer)v.getTag();
        if (position = ...){ do some stuff }
    }