I have not tried this, but it can work.
The ListView extends the ViewGroup, so when the ListView is 'long-clicked', the listener must be passed, the child view of which is under a long click.
Create your own ListView class that implements onLongClickListener, then check if the View is either a header or footer, and if so, return “true” to show that the long click has been consumed and indicate what to accept next measures.
protected MyListView extends ListView implements onLongClickListener { public boolean onLongClick (View v) { boolean longClickConsumed = false;
source share