Spinner is a component that provides a means of cycling through a list of items. The items are defined by the spinner's model data, specified via the "spinnerData" property. Spinners behave similarly to a single-select ListView or a ListButton, allowing a user to select one of the items in the list. However, unlike list views and list buttons, spinners only present a single item at a time.
Note that spinners may be "circular". When a spinner's "circular" property is set to true, the spinner's selection will wrap when it reaches the first or last item in the list. In the following example, the first spinner is circular, and the second is not:
Because spinner data is specified using an instance of the List interface, spinners are quite flexible. The second spinner in the above example uses an instance of NumericSpinnerData as its model. This class is a lightweight means of representing a list of numeric value options: it doesn't actually store the values as a list in memory - it simply calculates the appropriate value for a given index using its lower and upper bounds and increment value.
The BXML for this example is shown below:
<Window title="Spinners" maximized="true" xmlns:bxml="http://pivot.apache.org/bxml" xmlns:content="org.apache.pivot.wtk.content" xmlns="org.apache.pivot.wtk"> <BoxPane styles="{verticalAlignment:'center'}"> <Spinner spinnerData="['One', 'Two', 'Three', 'Four', 'Five']" circular="true" preferredWidth="80" selectedIndex="0"/> <Spinner preferredWidth="40" selectedIndex="0"> <spinnerData> <content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/> </spinnerData> </Spinner> </BoxPane> </Window>
Since this example contains no logic, there is no associated Java source.
Next: Calendars