Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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.

— asked July 30th 2010 by John Welch
  • dashboard
  • icons
  • images
0 Comments

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);
    }
    
    — answered July 30th 2010 by Goran Skledar
    permalink
    2 Comments
    • Basically, while the ImageView.image property can either be a url, Blob or file, I believe the DashboardView.image can only be a url at the moment.

      — commented July 30th 2010 by Goran Skledar
    • Err, DashboardItem.image that is :)

      — commented July 30th 2010 by Goran Skledar
  • 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.

    — answered July 30th 2010 by John Welch
    permalink
    1 Comment
    • You can also use the nativePath of the file.

      — commented July 26th 2012 by Adam Gressen
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.