Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,

I'm new to android platform and probably this is some simple question, but I cannot find answer nor in my books neither in google, maybe just using wrong keywords, so please don't be too harsh.

I need NumberPicker but also I need to make my application work for android 2.3.3.
I actually target my project to 4.0.3 sdk, but changed api version to 10 in manifest.
Version 10 doesn't have NumberPicker (actually it looks like it has, but it is hidden). I have implemented simple buttons + EditView for version 10, and create real number picker for 11 and above.
This part works fine, but when I target api 11 and above NumberPicker looks like this:
Good picker (shows selected number, previous number, next number, allows to scroll with finger, has triangle shaped buttons at top and bottom of the view)

Bad picker (doesn't fit inside the area, tries to show + and - android implemention of buttons and textview).

But it is the same control, created by exactly the same code, on the same phone/emulator, but it changes so drastically.

Is there some way to target version 10, but to make NumberPicker look like in good picker link above when executed on 4.0.3 devices?
Posted
Comments
kevinpelgrims 17-Oct-12 8:57am    
Did you ever find a nice solution for this? I'm currently trying to do the same...
skv_lviv 17-Oct-12 9:07am    
unfortunately, no.
Since I needed to get number from 1 to 10 I've replaced number picker with styled radio group. Of course it works, but it doesn't looks like standard control and user has to make additional click, so it isn't nice solution and it isn't what I wanted.
It looks that the only option is to write custom control...

After a lot of looking and trying and frustration I finally found this: https://github.com/SimonVT/android-numberpicker[^].
It's a NumberPicker based on the actual Android source, combined with a library to make the animations compatible with older versions.

If you still need a NumberPicker that looks like the one in Android 4.x, but is backward compatible, this is definitely the one!
 
Share this answer
 
v2
It looks like you are correct, the numberpicker control doesn't come into play until 2.3.4 (from what I have read) however a custom control should give you the same look and feel across all api levels.

Take a look at Custom control Number Picker[^]as an example of what is needed.

Hope it helps

/Darren
 
Share this answer
 
Comments
skv_lviv 22-Jun-12 6:44am    
Well, thanks, however I saw that article and currently I'm interested in having something like that for 2.3.3 (or for 2.3.3 and below) and standard look for above versions.
Maybe something between that one and the one in 4.0.3 will be developed in the future, but currently I just want to make standard control look in a way it is supposed to be. Do you know whether this is possible?
Darren_vms 3-Jul-12 10:30am    
Are you talking about the colours (theme used) then the answer is no, Someone on 2.3.3 could have an ICS theme and your picker would look like it does on 4.0.3.

Having a custom control picker should get you around any other issues

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900