Creating an iPhone like roller in Android using ListView
I want to create 开发者_C百科a better NumberPicker
then the one used in DatePicker
. I looked at the HTC Sense Alarm clock Roller (looks like the iPhone
Spinner/Roller), I want to create something like that.
I've created a ListView
that looks right, but I need a way to get the current id of the middle row. ListView.getFirstVisiblePosition()
kind of does what I want but it will give me +-1 errors. Another problem is that the scrolling should lock into a certain row when "dying" out. These are of course related and I hope I can solve this by using a custom ListView
, but it's hid in the API.
Any thoughts on how to solve this?
May be you can use this project on google code
https://code.google.com/p/android-wheel/
I did not tried it but seems that it works.
Why don't you try to replace those three ListView cells with ViewFlipper objects. As with their help you might be able to flip in the middle.
Trying to force ListView to behave as a kind of widget it is not seems like a bad approach. How about writing the widget yourself? If I was going to sit down and write such a thing in the platform, I definitely wouldn't try to build it on list view, nor probably any other widget. It makes sense as its own kind of thing.
精彩评论