How do I draw multiple images in settings?

The goal is to draw multiple images through settings. Does anyone know how to do so?

I currently have the following code after function onLayout(dc). Is the code correctly placed and written?

When I update in the simulator, the bitmap does not change...

function checkLoadedImage() {

        var system = System.getDeviceSettings().BackgroundImageTitle;

        if (system==false) {

                bitmap = WatchUi.loadResource(Rez.Drawables.imageI);

        } else {

          if (Application.getApp().getProperty("BackgroundImage") == 0) {

            bitmap = Ui.loadResource(Rez.Drawables.imageI);        

        } else if (Application.getApp().getProperty("BackgroundImage") == 1) {

            bitmap = Ui.loadResource(Rez.Drawables.imageII);

        } else if (Application.getApp().getProperty("BackgroundImage")==2) {

                bitmap = Ui.loadResource(Rez.Drawables.imageIII);

                                                        

  • You’ve shown code for selecting and setting bitmap but nowhere do you show where you use bitmap. 

    Do you have a bitmap draw command that uses it? Do you use a layout that sets something to it? If not: that’s your problem. 

  • I do see now what you mean regarding the selection and setting of bitmap.

    I currently have a dc.drawBitmap in the function onUpdate(dc) > View.onUpdate(dc) section.

    The function initialize also has bitmap = WatchUi.loadResource(Rez.Drawables...

    How would I rewrite the code properly? Is there a resource available to show how its written and where it's placed?

  • You want to load the bitmap in initialize and also based on onSettingsChanged().

    While it can be done each time onUpdate() is called, you really don't want to do this for each onUpdate().

  • the current bitmap (writing into initialize) loads into the watch face correctly. I shifted the code for the additional bitmaps (3 in total) into the initialize but it that did not load.

    Should the onSettingsChanged() be a function in itself, used to replace the Application.getApp, or included in the if statements?

  • i removed the code from view.mc and moved it to app.mc. on the initial sim run the main bitmap loaded, but then i tried selecting one of the bitmaps and it did not work.

    i believe i know how to load 1 bitmap...but how should 3 bitmaps be loaded while still enabling the user to select their image of choice?

  • Hello Jim,

    I tried many ways after I analyzed the link you sent but I am still having issues enabling the 3 images after they are "selected" in settings.

    Is the code written incorrectly? I placed it in the view.mc file and then tried in the app.mc file. What about the dc.drawBitmap written on the function onUpdate? Does it remain there? or remove?  

    function onSettingsChanged() {

            var system = System.getDeviceSettings().BackgroundImageTitle;

      var bmWidth=bitmap.getWidth();

            width=dc.getWidth();

            height=dc.getHeight();

            if (system==false) {

                    bitmap = WatchUi.loadResource(Rez.Drawables.imageI);

            } else {

     

              if (Application.getApp().getProperty("BackgroundImage") == 0) {

                bitmap = WatchUi.loadResource(Rez.Drawables.imageII);

              dc.drawBitmap(width/2-bmWidth/2,0, bitmap);              

                

            } else if (Application.getApp().getProperty("BackgroundImage") == 1) {

                bitmap = WatchUi.loadResource(Rez.Drawables.imageIII);

               dc.drawBitmap(width/2-bmWidth/2,0, bitmap);              

                

            } else if (Application.getApp().getProperty("BackgroundImage")==2) {

                    bitmap = WatchUi.loadResource(Rez.Drawables.HomageVermont100Ultramarathon);

              dc.drawBitmap(width/2-bmWidth/2,0, bitmap);              

                                                             

                }

                                  

            }

        }

  • is onSettingsChanged in your AppBase classs?  It won't work if you have it in your view.

  • I removed the onSettingsChanged from the app.mc and kept it after function initialize() and before function onLayout(dc). The sim showed only the original bitmap but did not change to the other images when selected in settings.

  • The name of the file doesn't matter.  It's the class you're looking for.

    Considering you say it's right before onLayout() says to me it's in your view class.

    it need to be in the class that starts with something like

    class <whatever name it has> extends Application.AppBase {