When you add clickable views (like buttons) in your item layout they catch the click event and it doesn't bubble to the underlying ListView
, to fix this you can add the long click listener to the items' root layout.
So instead of doing this in your activity:
ListView lv = (ListView) findViewById(R.id.lv);
lv.setOnItemLongClickListener(listener);
you do this in your adapter:
@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.item, parent, false);
view.setLongClickable(true);
view.setOnLongClickListener(listener);
}