android - How to have my ListView catch onLongClick() (not onItemLongClick) -



android - How to have my ListView catch onLongClick() (not onItemLongClick) -

i have listview refreshed @ high rate (3 times per second).

i need grab long press on such listview (as on parent layout); listview has it's height set wrap_content.

i can grab long click on parent layout, wish long click on item handled parent layout.

onitemlongclick not work due high refresh rate, have tried onlongclicklistener listview the long click not fired.

the rows set non-clickable, not-focusable items contained in row.

the question how handle long click anywhere in listview if position / item not matter?

i faced similar issue (with clicks on imagebuttons) when updating progress of downloads in listview.

the solution update individual rows instead of calling adapter.notifydatasetchanged() (as understand interferes click/touch listeners). problem find row accurately. need 2 things this:

mapping of url strings transfer objects (mpathtotransfers), list of urls (mpathkeys).

here's code adapter:

class="lang-java prettyprint-override">protected linkedhashmap<string, basetransfer> mpathtotransfers; protected list<string> mpathkeys; @override public int getcount() { mpathkeys = new arraylist<string>(mpathtotransfers.keyset()); homecoming mpathtotransfers.size(); } @override public basetransfer getitem(int position) { homecoming mpathtotransfers.get(mpathkeys.get(position)); } /** * update transfer (download) progress in listview's specific row */ public void setitemtransferredsize(string path, long transferredsize, listview lv) { if (mpathtotransfers.containskey(path)) { basetransfer ditem = (basetransfer) mpathtotransfers.get(path); ditem.settransferredsize(transferredsize); holder holder = getviewholderfortransfer(path, lv); if (holder != null) settransferprogressupdate(holder, ditem); } } /** * utilize view holder of row of transfer * * @param path * @param lv * @return {@linkplain holder} row, if visible, null otherwise */ private holder getviewholderfortransfer(string path, listview lv) { int rowindex = mpathkeys.indexof(path); if (lv.getfirstvisibleposition() <= rowindex && lv.getlastvisibleposition() >= rowindex) homecoming (holder) lv.getchildat(rowindex - lv.getfirstvisibleposition()).gettag(); else homecoming null; }

if have ambiguities, inquire in comments below (or in question's comments). :)

android listview long-click

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -