Git Product home page Git Product logo

androidwheel's Introduction

Wheel widget for Android

To include the wheel widget in the current layout, you should add in the layout xml this lines:

        <it.sephiroth.android.wheel.view.Wheel
            android:id="@+id/wheel"
            xmlns:sephiroth="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            sephiroth:numRotations="6"
            sephiroth:ticks="28" />

Where numRotations is the max number of rotations the wheel can perform and ticks is the total number of ticks the wheel will display.

In your activity you can add a OnScrollListener listener to the wheel widget, in this way:

	mWheel = (Wheel) findViewById( R.id.wheel );
	mWheel.setOnScrollListener( new OnScrollListener() {
		
		@Override
		public void onScrollStarted( Wheel view, float value, int roundValue ) {
		}
		
		@Override
		public void onScrollFinished( Wheel view, float value, int roundValue ) {
		}
		
		@Override
		public void onScroll( Wheel view, float value, int roundValue ) {
		}
	} );

Where float value is a value between -1.0 and 1.0 of the current indicator position and int roundValue is a value between -(ticksnumRotations) and (ticksnumRotations)

###Change the Wheel value The wheel position and value chan be changed programmatically at runtime using the Wheel's method setValue:

public void setValue( float value, boolean fireScrollEvent );
  • value is the new wheel value, a float between -1.0f and 1.0f, where 0.0f it's the center of the wheel.
  • fireScrollEvent: if true, once this method is called the onScrollFinished method will be called.

Screen Shots

Wheel running on ICS

androidwheel's People

Contributors

sephiroth74 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidwheel's Issues

setValue can not work

mWheel.setValue(1, false) seems not work in onCreate , but in OnScrollListener it works fine.

Error importing android wheel to my project

Hey there! I just imported this project to Eclipse to use it as library, but when I added this library to my project, a lot of errors appeared suddenly in my project... Errors were like this: R cannot be resolved to a variable. So, which is the correct way to import android wheel?

Numbers

Is there any way to put numbers to wheel instead vertical lines?

Set wheel position from code

Thank you for making this very useful widget. I need to set its starting position to something other than halfway - e.g. the total range is 0 to 100, but I want it to start at 30 rather than 50.

How can this be done?

can not run

there is no main class it.sephiroth.test.test.MainActivity

SetValue causes a "divide by 0" exception.

Using the setvalue method gives me a divide by zero exception.

My code is as follows:

            mWheel = (Wheel) v.findViewById(R.id.wheel);
            mWheel.setOnScrollListener( new Wheel.OnScrollListener() {

                @Override
                public void onScrollStarted( Wheel view, float value, int roundValue ) {
                    Log.i("SPINZ", "STARTED: f: " + value + " / i: " + roundValue);
                }

                @Override
                public void onScrollFinished( Wheel view, float value, int roundValue ) {
                    Log.i("SPINZ", "FINISHED: f: " + value + " / i: " + roundValue);
                    roundValue *= -1;
                    roundValue += 40;
                    if (roundValue >= 0 && roundValue < sections.length)
                        mSectionTV.setText(sections[roundValue]);
                }

                @Override
                public void onScroll( Wheel view, float value, int roundValue ) {

                    roundValue *= -1;
                    roundValue += 40;
                    if (roundValue >= 0 && roundValue < sections.length)
                        mSectionTV.setText(sections[roundValue]);
                }
            } );

            mWheel.setValue(1.0f, true);

If I take mWheel.setValue(1.0f, true) and move it to right after mWheel = (Wheel) v.findViewById(R.id.wheel), then I don't get the divide by zero exception, but the method doesn't do anything either.

Adding support for Android 2.1 and 2.2

Your wheel looks great & funny.
But, I must set API to >= 9 when build because in Wheel.java line 1084 you define a OverScroller (which only from API 9+). This mean I cannot run this app on Android 2.1 and 2.2.

Can you take time to add support for 2.1 and 2.2?

Thanks.

Use with minimal XML

Specifically, I'm trying to move the lines

sephiroth:numRotations="2"
sephiroth:ticks="20"

to code, so that I can externalize the wheel and change it at will in my app. However, I can't find a way to control these via java rather than xml.

Sample

Do you have any samples??

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.