如果用户手动完成,如何延迟自动刷过视图寻呼机

时间:2015-06-30 12:36:37

标签: android android-viewpager timertask

我有查看寻呼机显示来自网址的三张图片。在on create main class中,我设置了一个计时器,用于在一段时间后刷页。

  

问题在于同一方法集当前项被调用如何区分它是由计时器调用还是由用户手动调用。

我想做什么。

**我想延迟自动化或重置计时器,以便页面滑动不会受到后面运行的计时器的干扰。 **

需要您宝贵的建议。[code(pastebin)][1]

1 个答案:

答案 0 :(得分:2)

您必须覆盖活动

上的方法
/*
    Called whenever a key, touch, or trackball event is dispatched to the activity. 
    Implement this method if you wish to know that the user has interacted
    with the device in some way while your activity is running.

    Note that this callback will be invoked for the touch down action
    that begins a touch gesture, but may not be invoked for the touch-moved 
    and touch-up actions that follow.

*/
@Override
public void onUserInteraction() {
   super.onUserInteraction();
   postPoneAnimation();  << do your postponing there
}