Domanda

I'm working on widgets for my application. There should be a few widgets which make the same thing and only difference is in their layout (theme/appearance)

I would make a dialog or screen where the user can choose the widget which he likes. I saw this in a lots of widgets when I was choosing them.

Is there a option to have only one main widget class with different layouts file depends on user choice? Or I have to make a special class for each one?

Eventually can I change layout color in dialog or screen when user picked up one of them for example?

I would like to show to the user that there are some other widgets in paid version of my app. So when user is in choosing widget screen/dialog he should see all my widgets and see that in paid version are some premium ones.

Thank you for your suggestion

È stato utile?

Soluzione

Yes, it's possible. You can create one widget provider class and all the configuration will be done at the configuration activity, which can be called while creating a widget. Please take a look here. At this activity you can configure the widget and when it's done create preference file, which will contain all the settings for a newly created widget. You can name this file in a format myWidget<widgetID>. Later on, at your widget provider just read these files, taking ids from appWidgetIds and configure RemoteViews according to settings.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top