Android Studio - Problem loading widget (Toggle/Switch)

Viewed 148

I am trying to create a simple widget that has only a toggle button but I keep getting an error on my AVD emulator saying "Problem loading Widget".

It seems to be because I add a switch or toggle button to the widget layout.

To test it I created a new empty activity application, added a widget and then added a switch button.

enter image description here

The application builds and installs correctly but when I add the widget to my homepage on my emulator (Pixel 2 API 30) I get the following error.

enter image description here

I have checked logcat but can't see any errors in there. Does anyone know what I am doing wrong?

1 Answers

Sorry, but an app widget cannot have a Switch.

The documentation shows the list of available widgets and containers for app widgets. Switch is not among them.

Related