How to change the source of an image in a TableViewRow with name ?
Hey,
I am working on a first application on iPhone, so sometimes I meet problem. Today I would like to change the image source of some image (imageRead) whish are in view, whish are in a TableView. I think to give a name of my TableViewRow and access to image that it contains, but I don't know how to do… I am sorry for my bad English, I am French :-P
Thank you for your help !
(my code sample to explain)
var rows=[];
for(var i=0;i<items.length;i++) {
var row=Titanium.UI.createTableViewRow({
className:'item',
hasChild:false,
height:68,
name:'item'+items[i].id,
id_item:items[i].id,
url:'item.js'
});
var view=Titanium.UI.createView({
width:320,
height:68
});
var labelText=Titanium.UI.createLabel({
text:items[i].text,
left:12,
top:12,
height:28,
width:296
});
var imageRead = Titanium.UI.createImageView({
image:'images/read.png',
width:8,
height:8,
top:48,
left:left
});
view.add(labelText);
view.add(imageRead);
row.add(view);
rows.push(row);
}
var tableView=Titanium.UI.createTableView({
data:rows,
scrollable:true
});
For exemple I would like to change the imageRead source of the TableViewRow whish is named 'item1', what is the synthax, I would like something as like : tableView.getIndexByName('item1').child(imageRead).image = 'images/unread.png'; … ?
2 Answers
-
Accepted Answer
If you know the row no. you can use the following:
tblRow.children[X].image = 'images/newImg.png';
Where X = the row number -1 (Indexing)
-
I have tested this but it's negative…
tableView.getIndexByName('item1').children[0].children[1].image = 'images/unread.png';