Reputation: 143
I have a small view (call it "user-object") which overlap the background view (call it map). I can drag the "user-object".
I want the "user-object" automatically move to "mid-point" (screen_width/2, screen_height/2) after some seconds (for instance 4s) if three is no touch/drag.
Upvotes: 0
Views: 243
Reputation: 3256
An example using Handler
Handler mHandler;
public void useHandler() {
mHandler = new Handler();
mHandler.postDelayed(mRunnable, 1000);
}
private Runnable mRunnable = new Runnable() {
@Override
public void run() {
// Perform this here
"user-object" automatically move to "mid-point" (screen_width/2, screen_height/2)
mHandler.postDelayed(mRunnable, 1000);
}
After a drag/touch event is triggered, again apply handler.postDelayed()
.
Upvotes: 0
Reputation: 48
You can send a delay(3000ms) message at the beging and move "user-object" in the Handler's callback,If "user-object" was touched,remove the message
Upvotes: 1