LogoLogo
v7.0.0
v7.0.0
  • TotalCross Overview
  • TotalCross Javadoc
  • TotalCross Changelog
  • Roadmap
  • Documentation
    • Getting Started
      • First embedded project with TotalCross
    • Components
      • Accordion
      • Aligned Labels
      • Button
      • Check
      • ComboBox
      • Dynamic Scroll
      • Edit
      • Floating Button
      • Gpiod
      • Grid
      • GridContainer
      • Image
      • ImageControl
      • ImageList
      • Label
      • Material Icons
      • Material Window
      • MessageBox
      • Multi Edit
      • Progress Bar
      • Progress Box
      • Radio
      • Radio Group
      • Scroll Container
      • Side Menu
      • Slider
      • Sliding Window
      • Spin List
      • Spinner
      • Switch
      • Tabbed Container
      • Velocimeter
    • APIs
      • API Overview
      • API Rest
      • Asynchronous Task
      • Camera
      • Control
        • Main Window
        • Window
        • Container
      • GPS
      • HTTPS and SSL
      • JSON
      • Maps
        • Maps - Deprecated
        • Static Map
      • Material Design Standards
      • Ninepath
      • Notifications
      • PrinterManager
      • Push Notification Firebase
      • Scanner
      • SOAP
      • Socket
      • SocketServer
      • SQLite Encryption
      • QR Code Generator
      • totalcross.sys
      • Youtube API
    • Creating an Issue
    • Contributing
      • Branch workflow
      • Writing documentation
    • Guides
      • App Architecture
        • Suggested Architecture
        • Why do Design Patterns help with the application's organization?
          • MVC Architecture Pattern
          • Template Pattern
          • Data Persistence: DAO Pattern.
        • Separation of concepts: What is the best way to create UI interfaces?
        • Positioning
          • Manual Positioning
        • Relative Positioning
        • Best practices to improve project maintenance
      • Device Simulator
      • Package your app from scratch
        • TotalCross SDK
        • Environment Variables in IDE
          • Eclipse
          • IntelliJ
        • Deploy your app with a dependecy TC
        • Deploy iOS
          • Using Development certificate to test your apps
      • Understanding TotalCross for Linux ARM
      • Running C++ applications with TotalCross
      • Web Services
    • Miscelaneous
      • Java JDK 8
      • Maven
      • Installing Visual Studio Code
    • FAQ
      • IMEI in Android 10
Powered by GitBook
On this page
  • Overview
  • Source Code
  • Attributes
  • Methods
  • References

Was this helpful?

  1. Documentation
  2. Components

Spin List

Overview

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
import totalcross.sys.InvalidNumberException;
import totalcross.sys.Settings;
import totalcross.ui.Container;
import totalcross.ui.MainWindow;
import totalcross.ui.SpinList;
import totalcross.ui.gfx.Color;
import totalcross.util.UnitsConverter;

public class SpinListSample extends MainWindow {

    int gap = UnitsConverter.toPixels(DP + 8);

    public SpinListSample(){
        setUIStyle(Settings.MATERIAL_UI);
    }

    @Override
    public void initUI() {
        try {
            SpinList sl = new SpinList(new String[]{"Blue", "Orange","Yelow", "Red"});
            sl.allowsNoneSelected = true;
            add(sl, LEFT + gap, TOP + gap, FILL, PREFERRED);

            Container paintContainer = new Container();
            add(paintContainer, SAME, AFTER + gap, FILL - gap, FILL - gap);


            sl.addPressListener(e -> {
                switch (sl.getSelectedIndex()){
                    case -1:
                        paintContainer.setBackColor(Color.WHITE);
                        break;
                    case 0:
                        paintContainer.setBackColor(Color.BLUE);
                        break;
                    case 1:
                        paintContainer.setBackColor(Color.ORANGE);
                        break;
                    case 2:
                        paintContainer.setBackColor(Color.YELLOW);
                        break;
                    case 3:
                        paintContainer.setBackColor(Color.RED);
                        break;
                }
            });

        } catch (InvalidNumberException e) {
            e.printStackTrace();
        }
    }
}

Attributes

Type

Name

Description

boolean

isVertical

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

Methods

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.

int

getPreferredWidth()

Return the width.

int

getPreferredHeight()

Return the Height.

void

setChoices(String[] choices)

Sets the choices to the given ones

void

replaceChoices(String[] choices)

Just replaces the choices array.

int

getSelectedIndex()

Returns the selected index.

String

getSelectedItem()

Returns the selected item.

References

PreviousSliding WindowNextSpinner

Last updated 5 years ago

Was this helpful?

See the for more information.

Java Docs