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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:26:24+00:00 2026-06-11T14:26:24+00:00

I am following this question: How to stop scrolling in a Gallery Widget? I

  • 0

I am following this question: How to stop scrolling in a Gallery Widget?

I tried to implement my custom gallery like so:

public class CustomGallery : Gallery
    {
        public CustomGallery(Context context, IAttributeSet attrs) :
            base(context, attrs)
        {
            Initialize();
        }

        public CustomGallery(Context context, IAttributeSet attrs, int defStyle) :
            base(context, attrs, defStyle)
        {
            Initialize();
        }

        private void Initialize()
        {
        }

        public override bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
        {
            Keycode kEvent;
            if (isScrollingLeft(e1, e2))
            { //Check if scrolling left
                kEvent = Keycode.DpadLeft;
            }
            else
            { //Otherwise scrolling right
                kEvent = Keycode.DpadRight;
            }

            OnKeyDown(kEvent, null);

            return true;
        }

        private bool isScrollingLeft(MotionEvent e1, MotionEvent e2)
        {
            return e2.GetX() > e1.GetX();


        }
    }

I have referenced the custom gallery in my layout and I see the first image but nothing happens when I try scroll to the next image.

Strangely if I remove the override for OnFling I still don’t get any scrolling in my gallery? Surely if I don’t override anything my custom component should behave like the normal gallery component?

PS: All I am trying to do is prevent the Gallery from scrolling through multiple images when I swipe left or right, I want to scroll one image at a time.

Any help is appreciated!

  • 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-11T14:26:25+00:00Added an answer on June 11, 2026 at 2:26 pm

    Scratch this post, figured it out, I was ovveriding the OnTouch event in my Activity ><

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

Sidebar

Related Questions

Following up to this question , it seems like Select-Object sets its input to
Following this question , I'd like to know if there is a way to
I'm trying to start/stop Java threads in the following way. public class ThreadTester {
Following on from this question , I now want to know how to stop
Following this question and answer , I still have a bit trouble in the
Following this question, it seems that it is possible to open a file from
Following this question , I use this function to convert arrays to objects, function
Following up this question , I have a further problem - I have two
Following on from this question , I am interested in finding out how you
following on from this question (Developing to an interface with TDD), I'm still having

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.