Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Change button image inside table view row

$
0
0

I can't change the image of my button that is inside the table view row

Here is my code:

var win = Ti.UI.createWindow({
    backgroundColor : '#fff'
});
 
var tableData = [];
var toggle = false;
 
for(var i = 0; i < 10; i++) {
    var row = Ti.UI.createTableViewRow();
    var button = Ti.UI.createButton({
        image : 'image/check.png',
        width : 100,
        height : 40,
        buttonid : i    //our custom button property
    });
    row.add(button);
    tableData.push(row);
 
    button.addEventListener('click', function(e) {
    if(toogle){
        e.source.buttonid.img = 'image/check.png';
        toogle = false;
    }else{
        e.source.buttonid.img = 'image/uncheck.png';
        toggle = true;
    }
    });
}
 
var tableView = Ti.UI.createTableView({
    data : tableData
});
 
win.add(tableView);

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>