android - How can I get button pressed time when I holding button on -
i have button, press , continue holding it, if holding time exceeds time interval fires kind of intent, how can this.
try this
you can use touch listener
this.
try:
handler handel = new handler(); b.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view arg0, motionevent arg1) { switch (arg1.getaction()) { case motionevent.action_down: handel.postdelayed(run, 5000/* or amount of time want */); break; default: handel.removecallbacks(run); break; } return true; } });
where b
view
(in case should button) on want make long click.
and runnable
run
follows
runnable run = new runnable() { @override public void run() { // code run on long click } };
hope help... :)
Comments
Post a Comment