article

Amelia@Amazon avatar image
Amelia@Amazon posted

How to work around switch widget crashes in Android 5.0

Summary

In Android, developers can include two-state toggle switch widgets in their applications that allow users to select something between two options.

For more information, see here:

http://developer.android.com/reference/android/widget/Switch.html

Issue

This is a known regression in Android L; Android 5.0. If selected, the toggle widget will cause the app to crash.

Resolution

Though this has been fixed in Android 5.0.1, there is a workaround available for devices running Android 5.0 (which also works with lower versions of Android). Simply add the sample code below to the properties of your switch and it should no longer crash the overall application when selected at runtime.

Sample Code

 android:thumb="@drawable/my_thumb_icon" 
    android:track="@drawable/my_track_icon" 

Keywords: Widget, Runtime Crashes, Regressions, 5.0.1

KB_0027

androidlollipop
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Article

Contributors

brizzlebrazzle contributed to this article