Android does not have double-click events by default. I don't know why ~~.. Not to mention, go directlyCode.
First, add a double-click event interface:
Public interface ondoubleclicklistener {public void onsingleclick (view V); Public void ondoubleclick (view V );}
Then add a method:
/*** Register a double-click event * from a netizen and add handler for processing. If this is not added, it will cause errors such as thread security.
*/Public static void registerdoubleclicklistener (view, final ondoubleclicklistener listener) {If (listener = NULL) return; view. setonclicklistener (new view. onclicklistener () {Private Static final int double_click_time = 350; // double-click the interval of 350 milliseconds private Boolean waitdouble = true; private handler = new handler () {@ overridepublic void handlemessage (Message MSG) {listener. onsingleclick (View) MSG. OBJ) ;}}; // wait for double-click public void onclick (final view v) {If (waitdouble) {waitdouble = false; // run the double-click event new thread () {public void run () {try {thread. sleep (double_click_time);} catch (interruptedexception e) {// todo auto-generated Catch Block E. printstacktrace ();} // wait for the double-click time; otherwise, click the event if (! Waitdouble) {// If the waiting event or pre-execution double-click status is passed, it is deemed that waitdouble = true is clicked; message MSG = handler. obtainmessage (); MSG. OBJ = V; handler. sendmessage (MSG );}}}. start () ;}else {waitdouble = true; listener. ondoubleclick (V); // double-click it }}});}
Last registration event:
Imageview = (imageview) findviewbyid (R. Id. imageview1 );
Registerdoubleclicklistener (imageview, this );