I have to place an double click event on Image view..Whenever I double click on Image ,It sshould be Zoom.But I found that there is no such event like double click in Image Veiw. Can Anyone Tell me How To DO it?? Thanks in Advance..
Try this approach:
boolean doubleClick = false;
Handler doubleHandler
doubleClick is true
doubleClick
to true and use the handlers postDelayed
to set it back to false after i.e. 500ms whenever the onClick() is called the new instance of Handler is created, if the Handler object is instantiated inside onClick(). So, instantiate handler outside onClick().
boolean isDoubleClicked=false;
Handler handler=new Handler();
Runnable r=new Runnable(){
@Override
public void run(){
//Actions when Single Clicked
isDoubleClicked=false;
}
}
tv.setOnClickListener(new onClickListener){
@Override
public void onClick(View view){
if(isDoubleClicked){
//Actions when double Clicked
isDoubleClicked=false;
//remove callbacks for Handlers
handler.removeCallbacks(r);
}else{
isDoubleClicked=true;
handler.postDelayed(r,500);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With