2

替代文字

你好,我在一些安卓应用中看到了上面的控件。我知道它不是 Android 原生的,控件的名称是什么以及如何在 Android 中实现它?可以使用包含行为的 ListView 来完成吗?

4

3 回答 3

7

您还可以使用 NumberPicker 小部件,并使用显示的值作为您希望选择器显示的字符串。

NumberPicker picker = (NumberPicker) findViewById(R.id.np);
    picker.setMaxValue(5);
    String[] strs = {"Zero", "One", "Two", "Three", "Four", "Five" };
    picker.setDisplayedValues(strs);
    picker.setWrapSelectorWheel(true);
于 2012-10-08T03:20:33.857 回答
6

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.

于 2010-11-29T04:41:44.083 回答
3

您可以为 Android 制作自定义 Spinner,它只需要一些工作。我建议查看本教程,了解如何创建用户在启动 Spinner 之前看到的自定义视图:http ://www.gersic.com/blog.php?id=57 。

至于显示的实际视图......您需要考虑制作一个自定义 Adapter 对象,您可以将其传递给 Spinner 对象。为此,我可能会考虑扩展 Google 提供的适配器之一,甚至使用一个作为示例。有关适配器的更多信息,您可以查看适用于 Android 的 Google SDK:http: //developer.android.com/reference/android/widget/Adapter.html

不过,我确实同意 Dominik 的观点……您应该保持 Android 的外观和感觉以保持一致性。

于 2010-11-29T05:02:32.810 回答