Appcelerator leftImage
I'm trying to make my first mobile app using Appcelerator. When i try to load a local image into the array using "leftImage", the image doesn't show. However when i change the path to something that doesn't exist it tells me it can't find the path. I've googled it a lot and can't seem to find what i did wrong. Any help please?
var win1 = Titanium.UI.cr开发者_如何转开发eateWindow(
{
title:'test',
className:'win1',
backgroundColor:'#000000'
}
);
var vdata = [
{leftImage:'appicons/cloudy.gif',title:"Schedule"},
{leftImage:'appicons/shows.png',height:60, title:"Shows"},
{leftImage:'appicons/search.png', title:"Search"},
{leftImage:'appicons/friends.png',title:"Friends"},
{leftImage:'appicons/settings.png',title:"Settings"}
];
var table1 = Titanium.UI.createTableView({
data:vdata
});
win1.add(table1);
win1.open();
leftImage is the property of Titanium.UI.TableViewRow
So, you should use this:
var row = Titanium.UI.createTableViewRow({leftImage:'appicons/cloudy.gif',title:"Schedule"});
var table1 = Titanium.UI.createTableView({
data:row
});
win1.add(table1);
Ty this code
var tabledata;
var leftImage = ['appicons/cloudy.gif','appicons/shows.png','appicons/search.png','appicons/friends.png','appicons/settings.png'];
var title = ["Schedule", "Shows", "Search", "Friends", "Settings"];
for( var i = 0, len = title.length; i < len; i++)
{
var row = Ti.UI.createTableViewRow({
leftImage:leftImage[i],
title:title[i]
});
}
tabledata.push(row);
var table1 = Titanium.UI.createTableView({
data:tabledata
});
win1.add(table1);
You can also refer
http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.UI.TableViewRow-property-leftImage
Instead of using leftImage as a property of data, use leftImage property with Ti.UI.createtableViewRow
.
method 1:
var tblrow = Ti.UI.createTableViewRow({
leftImage : imageURL
});
method 2:
$.tblrow.leftImage = imageURL;
精彩评论