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 8762377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:31:04+00:00 2026-06-13T15:31:04+00:00

I have a ViewFlipper and in it, four scrollviews with layouts in those. I

  • 0

I have a ViewFlipper and in it, four scrollviews with layouts in those.

I use the following code (for each scrollview) to swipe:

ScrollView View1 = (ScrollView) findViewById(R.id.View1);
    View1.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub

            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                FirstX = (int) event.getX();
            }

            if (event.getAction() == MotionEvent.ACTION_MOVE) {
                int LastX = (int) event.getX();

                if (FirstX - LastX > SWIPE_MIN_DISTANCE) {
                    viewFlipper.setInAnimation(slideLeftIn);
                    viewFlipper.setOutAnimation(slideLeftOut);
                    viewFlipper.showNext();
                } else if (LastX - FirstX > SWIPE_MIN_DISTANCE) {
                    viewFlipper.setInAnimation(slideRightIn);
                    viewFlipper.setOutAnimation(slideRightOut);
                    viewFlipper.showPrevious();
                }
            }

            return true;
        }
    });

It works, but it looks like if I swipe from View 1 to View 2, I see a views 2 and 3 mixed together and it finally shows view 4.

So it seems the OnTouchListeners for each view are called after eachother.
How can I prevent this from happening?

A short and fast swipe does what it is supposed to do.

rg,
Eric

  • 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-06-13T15:31:06+00:00Added an answer on June 13, 2026 at 3:31 pm

    You should move your code you have in MotionEvent.ACTION_MOVE to MotionEvent.ACTION_UP to get a swipe. Now, if you don’t want swipe, and want to move the screen along with the finger, you should implement ViewPager as JafarKhQ just mentioned.

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

Sidebar

Related Questions

I have a LinearLayout , containg a ScrollView of ViewFlipper layouts. I've only included
I have a two layout in a ViewFlipper which contains ScrollView in each of
I have a vertical ScrollView (actually, a custom ScrollView, code below) within a ViewFlipper.
I have a ScrolLView that wraps a ViewFlipper. The content in the ViewFlipper is
I have a ViewFlipper which contains a few linear layouts. I need to allow
Basically, I have a ViewFlipper that flips when I swipe my finger on it.
I have a ViewFlipper which has some 10 views in it and each view
I have a TabHost that has two ViewFlippers, and inside each ViewFlipper are three
I have a viewFlipper with different ListViews in each flip. I have made all
Ans: Use viewFlipper.getCurrentView().getId() Hi, I'm stuck in a position where I have to execute

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.