Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14178] Android: Real Switch on Android

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-12-09T00:39:12.000+0000
Affected Version/sn/a
Fix Version/sRelease 4.0.0
ComponentsAndroid
Labelsexalture, module_switch, notable, qe-manualtest, qe-testadded
ReporterCarter Lathrop
AssigneeSunila
Created2013-06-10T10:51:20.000+0000
Updated2015-03-19T22:09:43.000+0000

Description

It would be nice to have a Real Android Switch when developing for Android 14 and above. The one supplied with Titanium now is not very nice.

Attachments

FileDateSize
settings_master_on_off_2.png2013-06-10T10:51:20.000+0000170058
switch2.jpg2013-06-11T08:06:49.000+00002792831

Comments

  1. Carter Lathrop 2013-06-10

    Hello Thomas, Have you tried using the holo themes and the UI components (eg. the switches) that come with that? By default the android UI features are from API level 8 but it is possible to get a different, more modern looking UI for API levels 14 and up by using the holo themes (light or dark). This should give you a nicer looking switch. For more reference: http://developer.appcelerator.com/question/130719/how-do-you-build-your-app-with-holo-theme Also, it is possible to create your own custom switch if what you are looking for is not available, but the holo theme'd switches should be fine for what you are asking. If you have any more questions or comments please feel free to ask. Regards, Carter
  2. Thomas Neerup 2013-06-11

    Hi Carter... I Attached a picture of a switch with halo enabled... and it does not look anything like the ones in settings.. I'm from denmark so Til = On :) Am I doing something wrong ?
  3. Carter Lathrop 2013-06-11

    Hi Thomas, Sorry for the confusion here, you are indeed right, the switches in Titanium are just Android toggles, unless specified as a checkbox, and there is a need for real switches that correlate to the native android UI. I will move this to engineering and they will process your request. Thanks for the suggestion. Regards, Carter
  4. David Bankier 2014-06-09

    Here's a native module for it: https://github.com/dbankier/RealSwitch
  5. Adam 2014-10-01

    David: Thanks for the module. I'm surprised the titanium dev's didn't include this in their recent 3.4.0 release... Android 4.0 has been out for quite some time now...
  6. Sunila 2014-11-07

    https://github.com/appcelerator/titanium_mobile/pull/6324 Added support for switch for ICS and older versions
  7. Ingo Muschenetz 2014-11-10

    Confirming that on SDK 14+ we should show a switch, otherwise a toggle. [~rblalock] [~aleard] [~grantges] Thoughts?
  8. Ingo Muschenetz 2014-11-17

    Okay, so the Titans would like access to both switch types. By default, use old style, pre-14, use new style post-14 But, allow option to use old style, post-14
  9. Malcolm Hollingsworth 2014-11-17

    Pre 14 we should default to the older square version. 14 and higher default to the newer and much better looking and correct version. However I suggest that the option to swap between is maintained so those that built a UI around the older square (ugly) version may continue to support that. I may be wrong but I thought there was a third-type switch native to Android. Whilst you are in there, throw it in if it does exist please.
  10. Ricardo Alcocer 2014-11-17

    [~core13], only two according to this: http://developer.android.com/guide/topics/ui/controls/togglebutton.html
  11. Stephen Feather 2014-11-17

    The 4.0+ switch can manifest itself with at least 2 different styles. !http://content.screencast.com/users/Stephen_Feather/folders/Jing/media/9d78e10c-aceb-46af-a7a3-89fdf3ce474d/00000705.png! one shown in the android docs, with the sharp razor edge feel, or the above.
  12. Malcolm Hollingsworth 2014-11-18

    Ricardo, yes but those are only the toggle subset, however - these were the others; http://developer.android.com/design/building-blocks/switches.html The existing switch on android provides a toggle button as default or a check box with a style property change. This however does not include the related radio version which would be a very welcome addition - even if the toggle state was left to the developer (assuming the action would not be handled automatically thus Appc work would be increased). So in reality we have; - Toggle Button / On Off Button - Check Box - Radio Button The UI of the On/OFF button changes massively between pre and post 4.x Android. Given the lack of a true Android 4.x UI version of the On/Off Button - many devs will have built UIs around the only alternative. Changing the UI to match one control is often not as easy as it sounds as large projects need sign off on UI changes. I welcome and beg for the correct 4.x On/Off - but other devs will need to be able to switch back. As Titanium appears to have created a synthetic version of the true/control (assuming that is the reason it did not inherit the correct style change in 4.x) then that should be maintained at least for a couple of releases. Notes; - Titanium.UI.Android.SWITCH_STYLE_CHECKBOX - Titanium.UI.Android.SWITCH_STYLE_TOGGLEBUTTON
  13. Lokesh Choudhary 2015-03-19

    Verified the implementation. Devices with API 14+ will see the new switch by default while API<14 will see the old version of switch. We can specify style:Titanium.UI.Android.SWITCH_STYLE_TOGGLEBUTTON_OLD for devices with API 14+ for the old version of switch. Closing. Environment: Appc Studio : 3.5.1.201412091616 Ti SDK : 4.0.0.v20150317234215 CLI : 4.0.0-alpha Alloy : 1.6.0-alpha MAC Yosemite : 10.10.2 Nexus 5: Android 5.0 Samsung Galaxy S3 : Android 4.0.4

JSON Source