I have a ListView
that is refreshed at a high rate (3 times per second).
I need to catch a long press on such a ListView
(as well as on the parent layout); the ListView
has it's height set to wrap_content
.
I can catch the long click on the parent layout, but I wish the long click on any item to be handled by the parent layout.
OnItemLongClick
does not work well due to the high refresh rate, I have tried the onLongClickListener
to the ListView
but the the long click is not fired.
The rows are set as non-clickable, not-focusable as well as all the items contained in the row.
The question is how to handle a long click anywhere in the ListView
if the position / item does not matter?
I faced similar issue (with clicks on
ImageButton
s) when I was updating progress of my downloads in aListView
.The solution was to update the individual rows instead of calling
adapter.notifyDataSetChanged()
(as what I understand is it interferes with your click/touch listeners). So to do this I problem was to find the row accurately. I need two things for this:Transfer
objects (mPathToTransfers
),mPathKeys
).Here's some code from my adapter:
If you have ambiguities, ask in comments below (or in your question's comments). :)