DataField - Best way to draw

I'm new to the Garmin SDK and I'm working on a custom Connect IQ datafield (a complex datafield, not simple)

Whats the best way of drawing the actual data field ? Should it be in onUpdate (dc) ? I see many calls to View.findDrawableById, but no calls to the drawing methods of the dc which is passed as a parameter to onUpdate. Which ones should I use ?

Basically I want to create a new Data Screen for my Epix Pro Gen 2 that shows multiple fields like the current time, timer, and a couple of my own custom calculations.

And the data screen would be a 1-field layout using a ConnectIQ data field. Something Similar to the Data Field "Walker" available in the Connect IQ store.

  • ok that makes sense. I'm a little confused about layouts, what is the advantage of using them vs a dc ?

  • What do you think, if you put the background in the layout then it won't be drawn every second?

    What's the difference between displaying a bitmap in a layout and drawing it in onUpdate?

  • You can have a layout xml per screen size (and shape) and your onUpdate is relatively easy.
    But you'll need to create the layout for each screen size you support.

    What I do instead is I calculate the positions in code. This may seem more complicated at the beginning, but I can just recompile my code every time there's a new device, without changing anything. (It might even not be needed in theory, and migration would be able to take care of it, though I don't think Garmin would migrate to a new screen size). Someone using layouts will need to create a new layout.

    But for me the biggest advantage of not using layouts was to save memory.

  • I incorrectly assumed that onLayout() would draw the main layout/design (once) and use onUpdate() to only update specific areas that needed updating.

  • ok i think i got it but I will re-read the documentation a few more times.. No mouth