ftp27
ftp27

Reputation: 903

Dynamically changing theme in Codename One from code

Need to download and apply styles, image buttons and someone else in runtime of app. Is such the function in Codename One? In the what format I need to download them?

Upvotes: 2

Views: 521

Answers (1)

Shai Almog
Shai Almog

Reputation: 52760

You can dynamically download a res file created by the designer and install it in runtime using:

Resources res = Resources.open(...);
UIManager.getInstance().setThemeProps(res.getTheme(themes[0]));

You can dynamically refresh the current UI with the new theme by using:

currentForm.refreshTheme();

See the kitchen sinks theme demo, although the themes aren't dynamically downloaded there the concepts should be easily understandable.

Upvotes: 3

Related Questions