Issues with Dashboard
I'm not sure what is going on here, the first section of code (just like the kitchen sink example) doesn't work but the second version I hacked together does:
for (var c=0;c<iconSet.length;c++)
{
var item = Titanium.UI.createDashboardItem({
image:Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, '/img/sporticons/image.png'),
selectedImage:Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, '/img/sporticons/image_on.png'),
label: labels[c] });
data.push(item);
}
for (var c=0;c<iconSet.length;c++)
{
var item = Titanium.UI.createDashboardItem({label: labels[c]});
var image = Titanium.UI.createImageView({
image: Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, '/img/sporticons/image.png')});
item.add(image);
data.push(item);
}
The problem with this I cannot specify a selected image with the dashboard.
2 Answers
-
Try this:
for (var c=0;c<iconSet.length;c++) { var item = Titanium.UI.createDashboardItem({ image:'img/sporticons/image.png', selectedImage:'img/sporticons/image_on.png', label: labels[c] }); data.push(item); }
-
Figured it out…
My project for some reason will not reference the images in a relative manner.
When I used Ti.Filesystem.getFile it was giving it a file as you said. What I needed was to add the Titanium.Filesystem.resourcesDirectory to the path of the image. It now works.
Thanks for the help.