Dynamically creating Widgets on Android

2019-02-24 19:04发布

Is it possible to create multiple widgets in runtime? Application (Activity) should generate in some cases new widget(or edit exist) with new name and label and do some primitive action on click, which should be available in desktop widgets menu.

2条回答
SAY GOODBYE
2楼-- · 2019-02-24 19:36

Is it possible to create multiple widgets in runtime?

No.

Application (Activity) should generate in some cases new widget(or edit exist) with new name and label and do some primitive action on click, which should be available in desktop widgets menu.

That is not possible. App widgets must be declared in the manifest, which cannot be modified at runtime.

Sorry!

查看更多
Explosion°爆炸
3楼-- · 2019-02-24 19:49

You can create a widget when its first added to the home screen, I dont like this idea though.

If you wanted you could declare X number of widgets in the manifest and create the Views in the onCreate() method.

查看更多
登录 后发表回答