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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:17:57+00:00 2026-06-16T21:17:57+00:00

I am trying to implement swiping between pages on my Application. I currently have

  • 0

I am trying to implement swiping between pages on my Application. I currently have 5 XML layout files which I access all from one Activity. There are five buttons on the bottom which represent each layout and when pressed switch to the corresponding XML layout.

I have tried to implement swiping using OnGestureListener, but it does not work as I would like it to. I need to swipe the Title of the view for the swiping to work. It does not work when I swipe across any of the Views shown in the layout.

I began looking and found the GestureOverlayView, which seems to be what I want. However, all of implementations I’ve found give me problems. Tutorial, Similar SO question.

This is the code that I have so far:

public class Monitor extends Activity implements android.view.GestureDetector.OnGestureListener, OnGesturePerformedListener {
    private GestureDetector gestureScanner;
    private GestureOverlayView gestures;
    private static final int SWIPE_MIN_DISTANCE = 50;
    private static final int SWIPE_THRESHOLD_VELOCITY = 50;
    private GestureLibrary gestureLib;

    public void onCreate( Bundle savedInstanceState ) {
        super.onCreate( savedInstanceState );
        gestures = new GestureOverlayView(this);
        View inflate = getLayoutInflater().inflate(R.layout.main, null);
        gestures.addView(inflate);
        gestures.addOnGesturePerformedListener(this);
        gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures); // Error here
        if (!gestureLib.load()) {
           finish();
         }
        setContentView(gestures);
}

I get an error on the line gestureLib = GestureLibraries.fromRawResource();. The error is raw cannot be resolved or is not a field.. There is no raw folder in my /project-name/res/ directory. Any ideas? Is there another way to do this?

This is how I first implemented the swiping capability, which only worked across the title bar.

public class Monitor extends Activity implements android.view.GestureDetector.OnGestureListener {
    private GestureDetector gestureScanner;
    private static final int SWIPE_MIN_DISTANCE = 50;
    private static final int SWIPE_THRESHOLD_VELOCITY = 50;
    public void onCreate( Bundle savedInstanceState ) {
        super.onCreate( savedInstanceState );
        gestureScanner = new GestureDetector(this);
        setContentView( R.layout.monitor );
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.i( "TouchEvent", "Here" );
        return gestureScanner.onTouchEvent(event);
    }

    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
        float velocityY) {
        if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE
            && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY
            ) {
            Log.i( "OnFling", "Right" );
            //ur code goes here.            
            if( getTitle().equals( getString( R.string.main_analogs ) ) ) {
                setContentView( R.layout.monitor );
                setTitle( R.string.main_monitor );
                buildButtons();
                if( hasRead ) {
                    updateMonitorForm();
                }
            }
        }
        /* on scroll to the previous page  */
        else if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE
            && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY
            ) {
            Log.i( "OnFling", "Left" );
            //Ur code goes here
            if( getTitle().equals( getString( R.string.main_monitor ) ) ) {
                setContentView( R.layout.analogs );
                setTitle( R.string.main_analogs );
            buildButtons();
                if( hasRead ) {
                    updateMonitorForm();
                }
            }
        }
        return false;
}
  • 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-16T21:17:58+00:00Added an answer on June 16, 2026 at 9:17 pm

    I am trying to implement swiping between pages on my Application. I
    currently have 5 XML layout files which I access all from one
    Activity. There are five buttons on the bottom which represent each
    layout and when pressed switch to the corresponding XML layout.

    This will be an ideal scenario for the ViewPager widget(unless you forgot to add other important details). You can manually swipe the ViewPager(so you don’t need to handle the touch events on your own) and you could also set the current page of the ViewPager with the setCurrentItem method(the Buttons part).

    I’ve made my little example based on your scenario. The sample it’s pretty self explanatory and you can find it here.

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

Sidebar

Related Questions

Trying to implement the following behavior on an iPad. I have a map-centric application
All I am currently trying implement something along the lines of dim l_stuff as
I am trying implement a search activity which gets data from a mysql table
I'm trying to implement swiping gestures for mobile devices in HTML/CSS & Javascript. It's
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
I am trying implement Unblock me Puzzle. i want to change image position from
Trying to implement a sphere example code I found here on stackoverflow I have
Trying to implement what I thought was a simple concept. I have a user
Trying to implement the following structure from c to use NSArray in objective-c: In
I have this weird kind of error. I am trying implement basic Euclidean algorithm

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.