Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6867279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:17:24+00:00 2026-05-27T03:17:24+00:00

My app contains a ViewFlipper with some images. when app starts, the ViewFlipper startflipping()

  • 0

My app contains a ViewFlipper with some images. when app starts, the ViewFlipper startflipping(). When user touch the screen ViewFlipper stopflipping(). I must do that after 60 seconds from last touch, ViewFlipper to start again flipping. My class implements onTouchListener and I have this method onTouch:

public boolean onTouch(View arg0, MotionEvent arg1) {


        switch (arg1.getAction()) {
        case MotionEvent.ACTION_DOWN: {

            downXValue = arg1.getX();
            break;
        }

        case MotionEvent.ACTION_UP: {

            currentX = arg1.getX();


            if (downXValue < currentX) {
                // Set the animation
                vf.stopFlipping();
                vf.setOutAnimation(AnimationUtils.loadAnimation(this,
                        R.anim.push_right_out));
                vf.setInAnimation(AnimationUtils.loadAnimation(this,
                        R.anim.push_right_in));
                // Flip!
                vf.showPrevious();
            }


            if (downXValue > currentX) {
                // Set the animation
                vf.stopFlipping();
                vf.setOutAnimation(AnimationUtils.loadAnimation(this,
                        R.anim.push_left_out));
                vf.setInAnimation(AnimationUtils.loadAnimation(this,
                        R.anim.push_left_in));
                // Flip!
                vf.showNext();
            }

            if (downXValue == currentX) {
                final int idImage = arg0.getId();

                vf.stopFlipping();
                System.out.println("id" + idImage);
                System.out.println("last touch "+getTimeOfLastEvent());

            }
            break;
        }
        }

        // if you return false, these actions will not be recorded
        return true;
    }

and I found this method, for finding time of the last touch :

static long timeLastEvent=0;
public long getTimeOfLastEvent() {

        long duration = System.currentTimeMillis() - timeLastEvent;
        timeLastEvent = System.currentTimeMillis();
        return duration;
    }

My question is : where should I call the getTimeOfLastEvent() ? If I put it on onTouch() I will never catch the moment when getTimeOfLastEvent==60000, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:17:24+00:00Added an answer on May 27, 2026 at 3:17 am

    What you should do is create a Handler (should be an instance variable of your Activity and should be initialized during onCreate):

    Handler myHandler = new Handler();
    

    Also you will need a Runnable that can start the flipping again (also needs to be declared within your Activity):

    private Runnable flipController = new Runnable() {
      @Override
      public void run() {
        vf.startFlipping();
      }
    };
    

    Then in your onClick you just post the Runnable on the Handler but delayed by 60 seconds:

    myHandler.postDelayed( flipController, 60000 );
    

    Posting it delayed means: “Run this code in 60 seconds”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help. In my android app I have a ViewFlipper that contains
I have an app that contains several activities...so lets say user is navigating activity
I have some problems with OnTouchListener . I want that everytime when user touch
I've created an app that contains 4 viewcontroller and its .h,.m files...In my firstviewcontroller
I've created an app which contains form and that have to filled up in
The original version of my app contains a UITableViewController that is pushed onto the
I have been working on an iPad app. My app contains some PDF and
Hi my app contains a refresh button,onclick of that I want to display list
My app contains a listview which can optionally contain images from a users sd
in my app Scrollview contains some views,i want to drag down the view,and at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.