如何在滚动时在NumberPicker中显示更多数字

问题描述 投票:1回答:1

如何在滚动时在numberpicker中显示更多项目/数字,因为它只显示3个数字。这是我的代码

 NumberPicker starttime = (NumberPicker) findViewById(R.id.timeListview);

    starttime.setMaxValue(47);
    String[] time = {"12:00 AM", "12:30 AM", "01:00 AM", "01:30 AM", "02:00 AM", "02:30 AM", "03:00 AM","11:00 PM", "11:30 PM"};
    starttime.setDisplayedValues(time);
    starttime.setWrapSelectorWheel(true);
android numberpicker
1个回答
1
投票

我已经更改了您的代码,请尝试这将有所帮助

NumberPicker starttime = findViewById(R.id.timeListview);
String[] time = {"12:00 AM", "12:30 AM", "01:00 AM", "01:30 AM", "02:00 AM", "02:30 AM", "03:00 AM","11:00 PM", "11:30 PM"};
    starttime.setMinValue(0);
    starttime.setMaxValue(time.length-1);
    starttime.setDisplayedValues(time);
    starttime.setWrapSelectorWheel(true);
© www.soinside.com 2019 - 2024. All rights reserved.