In my application I need to have a EditText where the values are numbers. I need to increase the value of EditText by scrolling up and need to decrease the value of EditText by scrolling down.
Example : DatePicker
The date changes by scrolling up and down. I need to have a EditText like in DatePicker.
Thanks in advance.
After some deep testing and using, this is a list of usable Picker widget libraries
Android Wheel http://code.google.com/p/android-wheel/
Number Picker from https://github.com/mrn/numberpicker
Date Slider (which can be easily adjusted) http://code.google.com/p/android-dateslider/
Horizontal slider widget http://blog.sephiroth.it/2012/01/28/android-wheel-widget/
Backport of Android 4.2 NumberPicker https://github.com/SimonVT/android-numberpicker
When kindly omitted the solution in accepted answer, these widget libraries are very usable if you need alter the design, and you like the way iOS does the wheel slider picker.
Related
I have a requirement to implement a horizontal date picker as shown in below image:
I have tried lots of libraries and googled it about for three days.
I customized this library but not able to style the selected item. i.e. Different color and size.
Please let me know, If is there any suggestion or sample code which can help me to implement the similar requirement.
HorizontalPicker is a custom-build Android View used for choosing dates (similar to the native date picker) but draws horizontally into a vertically narrow container. It allows easy day picking using the horizontal pan gesture.
resource :
https://github.com/jhonnyx2012/HorizontalPicker
https://github.com/GastricSpark/ScrollDatePicker
Is there a way to hide these numbers? Im guessing there must be an attribute which once set to 'false' should to it.
Also, i've tried to use custom drawables for the the up/down arrow, but those seem to overlay on top of the numbers (ie,the numbers are still visible)
Note: I could make custom pickers where I use a textView in between two imageViews, but the default timePicker allows one to swipe up and scroll through numbers (so would prefer using the default)
Edit: Apparently the NumberPicker has different children in different versions of android(the emulator shows the up/bottom arrows, while on my Samsung Tab they return a nullpointerexception). Wow!
Instead of using a time picker you could try and use a number picker instead, this means that you can specifically set what you want to be in the picker.
Is there a way to hide these numbers?
No, sorry.
Im guessing there must be an attribute which once set to 'false' should to it.
Only if you fork TimePicker and add such an attribute yourself.
Is there a simple spinner control in android with a text view increment and dicrement button. Pressing the button add or subtracts from the value displayed in the textview. I have been searching for such, but have not been able to find one.
Kind Regards
You can use NumberPicker if your target API is above 11.
I made a custom DatePicker that extends the android DatePicker UI component. I needed this to make possible the visibility option for each DatePicker's view component(day,month and year).
I made this possible by hiding the views from DatePicker by its index.
I get the index of each component by getting the date format order like this DateFormat.getDateFormatOrder(context) , this returns a char array like {m, d, y} so I can get the order of the DatePicker components and hide them..
The problem I run into is that on some devices the DatePicker position its components by the selected locale of the user and not by the selected date format.
How can I get the DatePicker's components order? Or how I can figure out that DatePicker will position its components by locale or date format?
Note that I am developing this on Android API level 2.1++ and I would prefer not to make my own DatePicker so I can preserve the android DialogPicker UI theme.
Thank you!
And unfortunately the answer is: I had to develop my own DatePicker and now everything works fine
I want to make an integer edittext field where the user can use plus/minus buttons to increment and decrement the integer value in the edittext field. I would like it to be just like the DatePickerDialog where you can change the day, month, year using little up and down buttons. Is there a standard Android widget that I can use to achieve this interface -- or is it necessary to piece it together myself using two buttons and an edittext field?
Update: this is a minSDKVersion API 7 app.
Yes use this..
This seems to be exactly what you are looking for
Number picker demo
Is that what you're looking for? number picker