i making app's have button performed action, want perform action when user long press on button.since google provides long press time duration appx .5 sec want customize time duration. please help...
you can try touch listener
this.
try:
handler handler = new handler(); b.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view arg0, motionevent arg1) { switch (arg1.getaction()) { case motionevent.action_down: handler.postdelayed(run, 5000/* or amount of time want */); break; case motionevent.action_cancel: handler.removecallbacks(run); break; case motionevent.action_up: handler.removecallbacks(run); break; } return true; } });
where b
view
on want make long click.
and runnable
run
follows
runnable run = new runnable() { @override public void run() { // code run on long click } };
hope helps... :)
Comments
Post a Comment