Hey there! I'm currently working on an Android application using Titanium. I've encountered a problem with changing images upon click using the code below. The issue is that the image only changes once, upon the first click. Subsequent clicks do not reflect the changed image visually, although the alert does indicate that the image source has been modified. Additionally, when clicking on the image (triggering the change), navigating to a child window, and then returning, the changes are not retained.
var feed_table = Ti.UI.createTableView({minRowHeight:5,hasChild:true});
var data = [];
for (var i=0;i<5;i++)
{
var row = Ti.UI.createTableViewRow({height:'auto',className:"row"});
var username = Ti.UI.createLabel(
{
text:'nilkash',
height:'auto',
font:{fontSize:12, fontFamily:'Helvetica Neue'},
width:'auto',
color:'#000',
textAlign:'left',
top:0,
left:35,
});row.add(username);
var doneCheckbox = Titanium.UI.createImageView(
{
id:'image_'+i,
clickName:'ClickName',
image:'../images/finished-work.png',
width:15,
height:15,
top:32,
left:0,
});row.add(doneCheckbox)
data.push(row);
}
feed_table.setData(data);
feedWin.add(feed_table);
feed_table.addEventListener('click',function(e)
{
if (e.source.clickName == 'ClickName' )
{
if(feed_table.data[0].rows[e.index].children[1].image == '../images/work.png')
{
feed_table.data[0].rows[e.index].children[1].image = '../images/finished-work.png';
}
else if (e.source.clickName == 'ClickName' )
{
feed_table.data[0].rows[e.index].children[1].image = '../images/work.png';
}
}
});
I also tried a simpler solution by toggling between two images, but even with this method, the changes are not retained. Do I need to reapply these changes to the table view each time? Thank you in advance for any assistance provided.