Noob question about drawing on a dc

Former Member
Former Member
Hello. Newbie here with a question to get me started. I have set up the SDK and Eclipse. I have managed to create and run a new watch face project, and also a new widget project on the simulator. I can see the monkey on the widget, and see the time on the watch face.

The problem I am having is that nothing I draw appears on the watch simulator screen. I am using the functions [FONT=Courier New]dc.setColor(Gfx.COLOR_RED, Gfx.COLOR_WHITE);[/FONT] and [FONT=Courier New]dc.fillRectangle(30, 30, 60, 60);[/FONT], etc, before [FONT=Courier New]View.onUpdate(dc); [/FONT]in the [FONT=Courier New]onUpdate(dc)[/FONT] function. The code compiles and the app launches on the simulator, but nothing I draw will appear on screen.

I looked in the example apps and I cannot see what I am doing any different. Any tips to get me heading in the right direction please?
  • The View.onUpdate() function clears the screen (by filling it with black) and then draws the layout if one has been set. Everything you draw before that will be overwritten.

    If you are using a layout, you will most likely want to call through to the base class method, but you need to do that first. If you are not using layouts, you don't need to call the base class method at all.

    Travis
  • Former Member
    Former Member over 8 years ago
    Thank you. I will take a look!
  • Former Member
    Former Member over 8 years ago
    Thank you. It works! Can I combine layouts and draw on the dc? Or do I have to choose one or the other?

    EDIT: Nevermind, I can draw after [FONT=Courier New]View.onUpdate(dc);[/FONT] :-)