开发者

UIPickerView look-alike on Android

开发者 https://www.devze.com 2023-01-28 10:19 出处:网络
开发者_开发技巧Hi, I have seen the above control in a few Android applications. I know it is not native to Android, what is the name of the control and how do I implement it in Android? Could it be

UIPickerView look-alike on Android

开发者_开发技巧Hi, I have seen the above control in a few Android applications. I know it is not native to Android, what is the name of the control and how do I implement it in Android? Could it be done using a ListView including the behavior?


You can also use NumberPicker widget with using displayed value to be strings you want picker to show.

NumberPicker picker = (NumberPicker) findViewById(R.id.np);
    picker.setMaxValue(5);
    String[] strs = {"Zero", "One", "Two", "Three", "Four", "Five" };
    picker.setDisplayedValues(strs);
    picker.setWrapSelectorWheel(true);


On iPhone it's called UIPickerView. I wouldn't recommend to exactly immitate its look, because it won't harmonize with the look of the other GUI widgets of android, which will result in some kind of a "cheap" look'n'feel for the user.


You can make custom Spinners for Android, it just takes some work. I suggest taking a look at this tutorial to see how to create the custom view the user sees before bringing up the Spinner: http://www.gersic.com/blog.php?id=57.

As for the actual view that is shown...you'll want to look into making a custom Adapter object that you can pass into the Spinner object. For this, I would probably look in to expanding on one of the Adapters Google has provided or even using one as an example. For more on Adapters you can look at the Google SDK for Android: http://developer.android.com/reference/android/widget/Adapter.html.

I do agree with Dominik though...you should stay with the Android look and feel to keep consistency.

0

精彩评论

暂无评论...
验证码 换一张
取 消