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
  • Attributes
  • Methods
  • References

Was this helpful?

  1. Documentation
  2. Components

Switch

PreviousSpinnerNextTabbed Container

Last updated 4 years ago

Was this helpful?

Overview

Switch is a element that chooses between two proportions

SwitchSample.java
 // Instance a simple switch
subtitles = new Switch();

 // Set the colors up
subtitles.colorBallOn = Color.getRGB(0,150,136);
subtitles.colorBarOn = Colors.P_700;
subtitles.colorBallOn = Color.getRGB(241,241,241);
subtitles.colorBarOff = Colors.P_200;

 // Positions the switch 
add(subtitles, RIGHT-hGap, SAME+lsfx.getHeight()/2, PREFERRED, PREFERRED);

This sample code is only from the Switch, to see the complete sample, including the Slider, go to

Attributes

Type

Name

Description

boolean

centerText

Boolean that center the text instead of move from left to right

int

colorBackOff

Background color for off switch

int

colorBackOn

Background color for on switch

int

colorForeOff

Foreground color for off switch

int

colorForeOn

Foreground color for on switch

String

textBackOff

Background text for off switch

String

textBackOn

Background text for on switch

String

textForeOff

Foreground text for off switch

String

textForeOn

Foreground text for on switch

Methods

Type

Name

Description

Constructor

Switch( )

Creates a simple switch

int

getPreferredHeight( )

Returns the switch minimum height

int

getPreferredWidth( )

Returns the switch minimum width

boolean

isOn( )

Return true if the switch is on

void

moveSwitch(boolean toLeft)

If true, move the switch to left

void

setOn(boolean b)

If true, turn on the switch

void

setPos(int x, int y)

Set the Switch´s x and y position

References

See the for more information.

github
JavaDocs