Giter Club home page Giter Club logo

numberpicker's People

Contributors

absimas avatar bernaferrari avatar dbarr33 avatar mariotaku avatar mgj avatar shawnlin013 avatar tibbi avatar tonyhaddad91 avatar viceboyz 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

numberpicker's Issues

Getter for typeface

It is nice to be able to set the typeface using setTypeFace(). A corresponding getter would be helpful, so I can do something like

mNumberPicker.setTypeface(mNumberPicker.getTypeFace(), Typeface.BOLD);

Issue with horizontal orientation

Hello,

I get the following issue when using horizontal orientation:

java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6588) at android.widget.ListView.measureHeightOfChildren(ListView.java:1282) at android.widget.ListView.onMeasure(ListView.java:1182) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615) at android.view.View.measure(View.java:17547) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2015) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1781) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:550) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Show the problem

I would like to ask how can I do this to show him 5 10 15 20 25 30 instead of 1 2 3 4 5 6 7 8 9 10

change minsdk to 15

Since the places where API 16 calls are made, there is already check for

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)

in the code, I think, minsdk should be 15 and not 16.

Change height/width

Hello!

Is there any chance to set number of currently visible rows except selected one?
Or is there any chance to hide all other rows except selected?

if I set
app:np_wheelItemCount="1"

when try to scroll the app crashes with IndexOutOfBounds exception
java.lang.ArrayIndexOutOfBoundsException: length=1; index=-1
at com.shawnlin.numberpicker.NumberPicker.incrementSelectorIndices(NumberPicker.java:1695)

WBR
Vadim

Feature Request: widget wider but without a wider divider

Hi there,

thanks for this lib. I got nuts on the bugs of the "native" one.

Right now I use the NumberPicker inside a FrameLayout, which is inflated into a DilaogFragment.

It would be nice to say android:layout_width="match_parent" in order to allow swiping next to the numbers. Then I want to say app:np_width="82dp" for quite a smale divider (only for visual purpose).

Best regards,
DaRolla

using app:np_height scales text size

Love the layout and everything, but unfortunately the text size scales with the np_height/width dimension. Here is how I tried to implement it.

    <com.shawnlin.numberpicker.NumberPicker
        
        app:np_height="30dp"
        app:np_textSize="20sp"
        
        android:id="@+id/snooze_duration_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:np_dividerColor="@color/colorSleepArc"
        app:np_max="60"
        app:np_min="0"
        app:np_textColor="@color/colorAccent"
        app:np_orientation="horizontal"
        app:np_value="5"
        android:layout_toEndOf="@+id/snooze_button"
        app:np_typeface="sans-serif-thin"
        />

np_orientation cannot be set

Hi

I don't seem to be able to set the orientation to vertical; I tried both modes, xml and java but the picker always render in horizontal.

Android 7.1.1 api25

picker dos not show negative number

hi ShawnLin013

i have a fragment with numberpicker
i call fragment and pass alarm.npminutes to it;
it has negative integer value , for example -19
this is my code:

  private void showNpminutesDialog(final Alarm alarm) {
        final FragmentTransaction ft = getFragmentManager().beginTransaction();
        final Fragment prevx = getFragmentManager().findFragmentByTag("npminutes_dialog");
        if (prevx != null) {
            ft.remove(prevx);
        }
        ft.addToBackStack(null);
        /* Create and show the dialog.*/
        final npminutesDialogFragment newFragment =
                npminutesDialogFragment.newInstance(alarm, alarm.npminutes, getTag());
        newFragment.show(ft, "npminutes_dialog");
    }

in fragment npminutesDialogFragment , i read alarm.npminutes by below ode:

    final int npminutes = bundle.getInt(KEY_NPMINUTES);

then i create dialog with numberpicker as below

       View v1x = getActivity().getLayoutInflater().inflate(R.layout.numberpicker, null);
        picker = (NumberPicker) v1x.findViewById(R.id.horizontal_number_picker);
        picker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
            @Override
            public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
                // do your other stuff depends on the new value
            }
        });
        picker.setValue(alarm.npminutes); // <==========   -19 
        picker.setMinValue(-59);
        picker.setMaxValue(59);
        picker.setWrapSelectorWheel(false);
        final AlertDialog alertDialog = new AlertDialog.Builder(context)
                .setView (v1x)
                .setPositiveButton(R.string.time_picker_set, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        set(alarm, tag);
                    }
                })
                .setNegativeButton(R.string.time_picker_cancel,
                        new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dismiss();
                        }
                })
                .setTitle("select plus/minus minute for alarm time")
                .create();
        return alertDialog;
    }

now when dialog opened with negative number , wheel show 20 instead -20

photo_2016-12-03_15-58-55

photo_2016-12-03_15-58-59

thanks alot for your library

Can we make custom divider ?

Hey,

It's a nice lib, thank you. I have a question can we make custom divider instead of the divider can we replace it with some circular view.

Is it possible to show multiple line strings?

I set the string to numberpicker ,but when the string item is too long.It can't show string completely.
(e.g. "Bonaire, Sint Eustatius and Saba" ,in numberpicker only show "naire, Sint Eustatius and Sa")

========
我遇到一個問題是當我放入string到numberpicker裡,都可以正常顯示但是在字數較長的項目中,他就會致中顯示並且切掉頭尾的字。

https://images.plurk.com/5iWgsLHdBR38UVF9kD7k.jpg

First value not formatted when using np_formatter or setFormatter()

When using np_formatter in xml or setFormatter() in java, all values except the first value are formatted correctly. However, when the user starts interacting with the NumberPicker the first value gets formatted.

screenshot_20170201-102314

String: <string name="number_picker_formatter">%1d ft</string>
XML:

<com.shawnlin.numberpicker.NumberPicker
            android:id="@+id/number_picker_length"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            app:np_width="64dp"
            app:np_height="180dp"
            app:np_dividerColor="@color/colorPrimary"
            app:np_formatter="@string/number_picker_formatter"
            app:np_max="24"
            app:np_min="1"
            app:np_textSize="16sp"/>

Java:

NumberPicker widthNumberPicker = (NumberPicker) getDialog().findViewById(R.id.number_picker_width);
widthNumberPicker.setFormatter(R.string.number_picker_formatter);```

Add support for negative values

<com.shawnlin.numberpicker.NumberPicker
android:id="@+id/number_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:np_width="64"
app:np_height="180"
app:np_dividerColor="@color/colorPrimary"
app:np_formatter="%02d"
app:np_max="7"
app:np_min="-7"
app:np_textColor="@color/colorPrimary"
app:np_textSize="30sp"
app:np_typeface="sans-serif-light" />

Caused by: java.lang.IllegalArgumentException: minValue must be >= 0

No disable feature?

No enable/disable feature yet, for disabling the spin when waiting for submitting data?
I was able to disable the layout using ViewGroup instances and disabling the children, but NumberPicker still can be spin but feels like buggy, constantly spinning...
Can it be fixed?
Thank You..

It's not getting the selected value?

There are a bunch of pickers in a dialog, I want the selected value to be stored in an int value so that I can use for other stuff..! but it's not seem to be working with me..!?

I've tried this

PicValue_1 = numberPicker1.getValue();
Log.i("PicValue_1 TEST_1", "" + numberPicker1.getValue());

the log never showed..!

then I've tried this.

numberPicker1.setOnValueChangedListener(new OnValueChangeListener() {
  @Override
  public void onValueChange(NumberPicker picker, int oldVal, int newVal) {

    PicValue_1 = newVal;
    Log.i("PicValue_1 TEST_2", "" + numberPicker1.getValue());

    Toast.makeText(MainActivity.this, "picker changed from  " + numberPicker1.getValue() + "|" + oldVal + " to " + newVal  , Toast.LENGTH_SHORT).show();

  }
});

..But the log never showed again neither the toast..!? I tried to move the listener inside the dialog button event listener, but no luck..? what I'm doing wrong..!

Wrap Selector Wheel Setting Ignored

When setting min/max values for the number picker, the global boolean for wrapping the selector wheel is overwritten by the following lines:
boolean wrapSelectorWheel = mMaxValue - mMinValue > mSelectorIndices.length; setWrapSelectorWheel(wrapSelectorWheel);

Selection of Numbers

I was wondering if it was somehow possible to disable the selection on the first touch so the user can only scroll through the different numbers?

selection_setting

Initial value is blank when using formatter

It seems like the initial value is blank when i'm using a formatter:
with_formatter

It functions fine, but the value only appears after I've spun the number picker.

When I don't specify a formatter, it works fine:
without_formatter

The formatter I have is very simple - I just need increments of 5 instead of 1:

class StepFormatter implements com.shawnlin.numberpicker.NumberPicker.Formatter {
        @Override
        public String format(int value) {
                return "" + value*5;
                }
};

Fading edges not working.

Hi I have been not been able to get the fading edges to work. I have tried both in xml and in code.

android:fadingEdgeLength="10dp"
android:fadingEdge="horizontal"
android:fadeScrollbars="true"


snoozeDurationPicker.setHorizontalFadingEdgeEnabled(true);

Thanks

ANR when wrap=false and wheelItemCount is set to >= 6

Steps to reproduce:

  • Checkout the sample
  • Open the layout file
  • Edit number_picker and set:
app:np_wheelItemCount="7"
app:np_wrapSelectorWheel="false"
  • Scroll to the bottom of the numberpicker, ANR will happen
  • ANR also happens when scrolling down and going back to top of numberpicker again

I wasn't able to get ANR with the value of 6 or lower.

Numbers drawn with wrong position

The following image represents the problem. I divided the screen proportionally, and was able to see the that top and bottom numbers are drawn differently.

I've used the code from sample and just add some lines to represent the problem.

device-2017-08-22-141136

Items order

First of all, thank you for an awesome library!
It would be cool to add possibility to change an order of numbers to opposite, especially useful for vertical orientation in my case.

Set min and max value from code

Thanks for this awesome widget! Could you add a function to set the min and max value from code also and not just xml?
Thanks!

Failed to find style 'numberPickerStyle' in current theme

I keep getting this error in Android Studio when previewing the layout. Do I need to declare a style in my theme for the numberPickerStyle attribute? The sample app does not appear to have anything like that. Thanks!

Failed to find style 'numberPickerStyle' in current theme

Wrong data shown after setDisplayedValues

I have a situation, where setDisplayedValues is called much later after view initialization, because data are coming from a remote service. In this case data showed by NumberPicker is totally wrong (they are overlapping and has wrong scroll behavior).
I could fix this behavior by replacing initializeSelectorWheelIndices with initializeSelectorWheel.

Patch:
reinitialize_wheel.txt

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.