Spin list is a control that has two arrows (up and down) to navigate between the information contained in the control, it is possible to navigate by clicking or holding the arrows or navigating the keyboard arrows.
Source Code
SpinList Sample
importtotalcross.sys.InvalidNumberException;importtotalcross.sys.Settings;importtotalcross.ui.Container;importtotalcross.ui.MainWindow;importtotalcross.ui.SpinList;importtotalcross.ui.gfx.Color;importtotalcross.util.UnitsConverter;publicclassSpinListSampleextendsMainWindow {int gap =UnitsConverter.toPixels(DP +8);publicSpinListSample(){setUIStyle(Settings.MATERIAL_UI); } @OverridepublicvoidinitUI() {try {SpinList sl =newSpinList(newString[]{"Blue","Orange","Yelow","Red"});sl.allowsNoneSelected=true;add(sl, LEFT + gap, TOP + gap, FILL, PREFERRED);Container paintContainer =newContainer();add(paintContainer, SAME, AFTER + gap, FILL - gap, FILL - gap);sl.addPressListener(e -> {switch (sl.getSelectedIndex()){case-1:paintContainer.setBackColor(Color.WHITE);break;case0:paintContainer.setBackColor(Color.BLUE);break;case1:paintContainer.setBackColor(Color.ORANGE);break;case2:paintContainer.setBackColor(Color.YELLOW);break;case3:paintContainer.setBackColor(Color.RED);break; } }); } catch (InvalidNumberException e) {e.printStackTrace(); } }}
Set to true if there are only numbers in the SpinList and you want to open a NumericBox
boolean
useNumericBox
Set to true if there are only numbers in the SpinList and you want to open a NumericBox
boolean
useCalculatorBox
Set to false to disallow the wrap around that happens when the user is at the first or last items.
boolean
wrapAround
By default, equals the choices' length. You can define its length and then create a single array shared by a set of SpinLists with different lengths on each SpinList
boolean
allowsNoneSelected
Allows -1 as selected index
Type
Name
Description
Constructor
SpinList(String[] choices)
Constructs a vertical SpinList with the given choices, selecting index 0 by default.
Constructor
SpinList(String[] choices, boolean isVertical)
Constructs a SpinList with the given choices, selecting index 0 by default and can be vertical or not.