<resources>
<string id="Instructions">Press Up/Down to Navigate</string>
</resources>
<resources>
<string id="Instructions">Swipe Left/Right to Navigate</string>
</resources>
class MyView extends Ui.View
{
var instructions;
function onLayout(dc) {
instructions = Ui.loadResource(Rez.Strings.Instructions);
}
}
class MyView extends Ui.View
{
function onLayout(dc) {
var device = Ui.loadResource(Rez.Strings.Device);
if ("fr920xt".equals(device)) {
// this is a 920
}
}
}
That said, I'd recommend against doing it this way unless you really have to. It requires various parts of your code to know what device they are running on, which can be problematic when adding support for additional devices. If you use layouts, everything that is specific to the device ends up in the device-specific layout file. Unfortunately, the cost of using a layout is pretty high (4kB for a layout with a background, some lines and 8 labels in my testing). IMO the cost is worth the benefit in many cases, since porting to a new device requires only editing a single file.
Ken - feature request - what if there was a way to know in something like system>device settings. A simple method with an ENUM, with that value being negative, to indicate that you're also in the simulator?
If the widget knew it was in the simulator, it would know that it had to work a bit differently.
Granted that the simulator will probably change to allow toggling phoneConnected, but there could be other things like this, and waiting weeks for the simulator to be fixed could be a pain.
class MyView extends Ui.View
{
function onLayout(dc) {
var device = Ui.loadResource(Rez.Strings.Device);
if ("fr920xt".equals(device)) {
// this is a 920
}
}
}
VA
<font id="xtiny">Roboto 12</font>
<font id="tiny">Roboto 12</font>
<font id="small">Roboto 12</font>
<font id="medium">Roboto 17</font>
<font id="large">Roboto 20</font>
<font id="numberMild">Roboto 20 Number</font>
<font id="numberMedium">Roboto 32</font>
<font id="numberHot">Roboto 38</font>
<font id="numberThaiHot">Roboto 62</font>
920xt
<font id="xtiny">Digi 12</font>
<font id="tiny">Digi 12</font>
<font id="small">Digi 12</font>
<font id="medium">Digi 17</font>
<font id="large">Digi 20</font>
<font id="numberMild">Digi 20</font>
<font id="numberMedium">Digi 32</font>
<font id="numberHot">Digi 38</font>
<font id="numberThaiHot">Digi 62</font>
Epix
<font id="xtiny">Roboto 12</font>
<font id="tiny">Roboto 12</font>
<font id="small">Roboto 12</font>
<font id="medium">Roboto 17</font>
<font id="large">Roboto 20</font>
<font id="numberMild">Black Diamond 20</font>
<font id="numberMedium">Black Diamond 32</font>
<font id="numberHot">Black Diamond 38</font>
<font id="numberThaiHot">Black Diamond 62</font>
F3
<font id="xtiny">Roboto 12 Bold</font>
<font id="tiny">Roboto 14 Bold</font>
<font id="small">Roboto 17</font>
<font id="medium">Roboto 19</font>
<font id="large">Roboto 24 Bold</font>
<font id="numberMild">Steelfish 22</font>
<font id="numberMedium">Steelfish 40</font>
<font id="numberHot">Steelfish 54</font>
<font id="numberThaiHot">Steelfish 75</font>
Does this work on the simulator?