so i have a heart icon Im including dynamically based on a user setting.
I just got above working... So its a drawable so it gets written via dc.drawBitmap(...,HeartRateIcon) after the View.onUpdate(dc);
Now i want to display the actual Heart Rate over that.... Be4 when it wasn't dynamic, it was easy (since layout items just get written incrementally stacked on top of each other)...
Now all the layout.xml labels get written to View first, and when the Heart Icon show sup dynamically it is placed over the Heart Rate label...
So i removed the HeartRateLabel from the layout.xml, and initially put it under drawables.xml (then i realized text/labels aren't allowed in drawables to load as a resource)...
So im thinking i have to create the label dynamically via pure MonkeyC code so it gets placed after the dc.drawBitmap(...,HeartRateIcon) so it shows up on top of the Icon... but can't seem to find any code online to do this?
I searched the documentation and found a Text.initialize(dictionaryOptions) method which returns a Text obj i think, but that caused errors ... got UnexpectedTypeException: Expected Method, given Class definition... tried Ui.Text.Initialize(...) as well:
if( setting_ShowHeartRate) {
dc.drawBitmap( (dc.getWidth()/2) - 20, 142, heartRateIcon);
heartRateLabel = Text.initialize({ "text" => ActivityMonitor.getHeartRateHistory(1,true).next().heartRate, "color" => Gfx.COLOR_WHITE, "backgroundColor" => Gfx.COLOR_TRANSPARENT, "font" => Gfx.FONT_SMALL, "justification" => Gfx.TEXT_JUSTIFY_CENTER }); //not sure if this should be literally ":text" as the documentation says or "text"
heartRateLabel.setLocation( (dc.getWidth()/2) , 147);
}
UPDATE: I have a ghetto solution for now... keep the original HeartRate icon defined the layout.xml... add the Text Label as usual via the layout.xml as well and populate the label's heartrate value with the java code...
and if setting_ShowHeartRate is turned off, I place a black PNG over entire the Heart icon/label to 'black it out' hehe. I would still like to know a better way to approach this.