java - Make sub-View Listen for Double-Click in AndroidStudio -


i have following code in oncreate method of activity:

gridlayout gridlayout = new gridlayout(this); gridlayout.setcolumncount(5); gridlayout.setrowcount(5); (int = 0; < 25; i++) {     imageview imageview = new imageview(this);     gridlayout.addview(imageview, i); } setcontentview(gridlayout); 

now, i'd each imageview in gridlayout respond (listen for) double-click. how can go doing this? (i've used long-press on 1 of views perform different action can't use instead, although realize easier since there's native listener it.)

you have 2 options:

1) use boolean handler (like this answer)

  • add boolean doubleclick = false;
  • and handler doublehandler
  • in onclick check if doubleclick true
    • if true, double click
    • if not, set doubleclick true , use handlers postdelayed set false after i.e. 500ms

2) use gesturelistener ( ondoubletap() method )


Comments

Popular posts from this blog

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -