cannot find function createDashboardItem in object Ti.UI ( Titanium Mobile )
i am creating simple dashboard view in which i using createDashboardItem function item has to set on dashboard.
code look something like this error is on line 3 that function createDashboardItem not found i am using Titanium Mobile SDK 1.6 and testing using android simulator SDK 2.2 API
i am creating simple dashboard view in which i using createDashboardItem function item has to set on dashboard.
code look something like this error is on line 3 that function createDashboardItem not found i am using Titanium Mobile SDK 1.6 and testing using android simulator SDK 2.2 API
var win = Titanium.UI.currentWindow;
var data 开发者_如何学运维= [];
var item = Titanium.UI.createDashboardItem({
image:'/images/item1_off.png',
selectedImage:'/images/item1_on.png',
label:'Item 1'
});
data.push(item);
var dashboard = Titanium.UI.createDashboardView({
data:data
});
win.add(dashboard);
You're getting this error because dashboard views are not currently implemented to Android platform.
As you can see in the Titanium API reference, there's no android icon right to the object name. DashboardView Here you got an example of both android and apple platform compatible object :Label
DashboardView may be available in upcoming release, but for now, you'll have to create you own dashboards...
Regards.
Here is how I made my own (also, that little icon is very hard to miss)
The one thing that is missing from this example is the button listeners
var data = [];
var labels = ['events','dine','activities','kids','golf','casino','map','info','weather'];
for (var x=0;x<2;x++)
{
for (var c=0;c<labels.length;c++)
{
if (Titanium.Platform.name == 'android') {
var left = ((c%3)*100)+15;
var top = (Math.floor(c/3) * 100) + 15
var item = Titanium.UI.createButton({
backgroundImage:'../img/icon_'+labels[c]+'.png',
width:77,
height:78,
top:top,
left:left
});
data.push(item);
} else {
var item = Titanium.UI.createDashboardItem({
image:'../img/icon_'+labels[c]+'.png'
//label:labels[c]
});
data.push(item);
}
}
}
if (Titanium.Platform.name == 'android') {
// Android Dashbaord
var dashboard = Titanium.UI.createView({
});
for(var k=0; k<data.length; k++) {
dashboard.add(data[k]);
}
} else {
// iPhone Dashboard
var dashboard = Titanium.UI.createDashboardView({
data:data,
top:15
});
}
精彩评论