Giter Site home page Giter Site logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
At the beginning the wheel control was designed only for displaying simple 
items w/o any control specific features like click events or animation.

It is a base control and of course it does not meet all your expectation :)
But it is possible to extend its functionality according to your needs.

Original comment by [email protected] on 12 Aug 2011 at 8:25

from android-wheel.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
I've observed differences between ListView and your Wheel sources with respect 
to handling onTouch events (and applying them to children items) and coundn't 
find out how to 'fix' wheel.

What exactly I need to change to get desirable functionality?

Thank you.

Original comment by [email protected] on 12 Aug 2011 at 8:59

from android-wheel.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
I'll investigate and let you know.
Thank you

Original comment by [email protected] on 12 Aug 2011 at 9:09

from android-wheel.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
To allow clicks on the current item look for the onTouchEvent method in 
WheelView and replace the line:
  if (items != 0 && isValidItemIndex(currentItem + items)) {
with:
  if (isValidItemIndex(currentItem + items)) {
or if you want to allow ONLY clicks on the current item:
  if (items == 0 && isValidItemIndex(currentItem)) {

Unfortunately even a 1 pixel movement with cause a scroll instead of a click. 
You might have to tweak the scrolling mechanism to consider a scroll < 10 
pixels (or something) a click too. For example by creating a member and 
constant:
  protected int scrolledDistance;
  private static final int MIN_DELTA_FOR_CLICKING = 25;
in WheelView and replacing the scrolling listener code with:

    // Scrolling listener
    WheelScroller.ScrollingListener scrollingListener = new WheelScroller.ScrollingListener() {
        public void onStarted() {
            isScrollingPerformed = false;
            scrolledDistance = 0;
            notifyScrollingListenersAboutStart();
        }

        public void onScroll(int distance) {
            doScroll(distance);

            scrolledDistance += Math.abs(distance);
            if (scrolledDistance > MIN_DELTA_FOR_CLICKING) {
                isScrollingPerformed = true;
            }

            int height = getHeight();
            if (scrollingOffset > height) {
                scrollingOffset = height;
                scroller.stopScrolling();
            } else if (scrollingOffset < -height) {
                scrollingOffset = -height;
                scroller.stopScrolling();
            }
        }

        public void onFinished() {
            notifyScrollingListenersAboutEnd();

            scrollingOffset = 0;
            invalidate();
        }

        public void onJustify() {
            if (Math.abs(scrollingOffset) > WheelScroller.MIN_DELTA_FOR_SCROLLING) {
                scroller.scroll(scrollingOffset, 0);
            }
        }
    };

Original comment by [email protected] on 9 Nov 2011 at 11:07

from android-wheel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.