Very new. Seeking understanding via the samples. I have an app that allows uses to pick a number from a picker. I want to be able to cycle through the varios picks over time and gernate a 'table' that persists each of the picks in a view and the time of pick. What is a way to link each new pick to a list item? I tried a counter but only get the last pick.
My picker sets a key with a counter.
function onAccept(values) {
var drink;
var drink_time;
drink = new [10];
drink_time = new [10];
countD = countD +1;
System.println("on accept values " + countD);
drink[countD] = values[0] + WatchUi.loadResource(Rez.Strings.drinkSeparator) + values[2];
drink_time[countD] = GetTimeStringShort();
var drink_num = drink[countD].toFloat();
var drink_plus = drink_num + 1;
Application.getApp().setProperty("drink"+countD, drink[countD]);
Application.getApp().setProperty("drink_time", drink_time[countD]);
WatchUi.popView(WatchUi.SLIDE_IMMEDIATE);
System.println("drink plus " + drink_plus);
System.println("drink[] " + drink);
//Save.drink[countD];
//Save.drink_time[countD];
}
}
My list view attempts to display the picks.
function onShow() {
var app = Application.getApp();
// find and modify the labels based on what is in the object store
// drink number
// number 1
var drink = findDrawableById("drink"+countD);
var drink_time = findDrawableById("drink_time");
var prop = app.getProperty("drink"+countD);
if(prop != null) {
drink.setText(prop);
}
else {
drink.setText(Rez.Strings.drink);
}
prop = app.getProperty("drink_time");
if(prop != null) {
drink_time.setText(prop);
}
else {
drink_time.setText(Rez.Strings.drink_time);
}
}
Layout attmpts to pick each item up.
<layout id="ListLayout">
<label id="drinkListHeader" font="Graphics.FONT_TINY" x="center" y="8" justification="Graphics.TEXT_JUSTIFY_LEFT" color="Gfx.COLOR_BLACK" text="Feed Log" />
<label id="drink_time" font="Graphics.FONT_XTINY" x="40" y="15" justification="Graphics.TEXT_JUSTIFY_LEFT" color="Gfx.COLOR_WHITE" text="--" />
<label id="drink" font="Graphics.FONT_XTINY" x="90" y="15" justification="Graphics.TEXT_JUSTIFY_LEFT" color="Gfx.COLOR_WHITE" text="--" />
<label id="drink_time1" font="Graphics.FONT_XTINY" x="40" y="35" justification="Graphics.TEXT_JUSTIFY_LEFT" color="Gfx.COLOR_WHITE" text="--" />
<label id="drink1" font="Graphics.FONT_XTINY" x="90" y="35" justification="Graphics.TEXT_JUSTIFY_LEFT" color="Gfx.COLOR_WHITE" text="--" />
<label id="drink_time2" font="Graphics.FONT_XTINY" x="40" y="55" justification="Graphics.TEXT_JUSTIFY_LEFT" color="Gfx.COLOR_WHITE" text="--" />
.... etc
Then eventually id like to perform some calculations as items are chosen.
Regards,
Brad