for ( i = 0; i < 10; i++) {
var YPos = 30;
var Label1 = Ti.UI.createLabel({
left : 0,
top : YPos ,
width: "50%",
backgroundColor: "blue",
height: 20,
text: i.toString(),
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
});
var Label2 = Ti.UI.createLabel({
left : "50%",
top : YPos ,
width: "50%",
backgroundColor: "blue",
height: 20,
text: i.toString(),
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
});
YPos += 30;
};
I would not like to use again and again the following block of code in loop.
width: "50%",
backgroundColor: "blue",
height: 20,
text: i.toString(),
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
I am using Alloy. I assigned as class as below
var Label2 = Ti.UI.createLabel({
left : "50%",
top : YPos ,
class:"CommonPro"
});
in .tss file
".CommonPro":
{
width: "50%",
backgroundColor: "blue",
height: 20,
text: "Bla Bla",
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER
}
Also i used to className:"CommonPro" properties for label but nothing changed.
How approach must i try?
Thanks in advance.