JV.
JV.

Reputation: 2698

Appcelerator Titanium tableviewrow rightImage not working on Android device

I am new to Titanium.

I have a tableview displaying some data. I have added an event listener on each row to toggle the display of the check image (rightImage) like this:

row.addEventListener('click', function(e){
    if(e.row.getHasCheck()){
            e.row.setHasCheck(false);
            e.row.rightImage = 'android/images/blank.png';
            e.rowData.rightImage = 'android/images/blank.png';
        } else {
            e.row.setHasCheck(true);
            e.row.rightImage = 'android/images/check.png';
            e.rowData.rightImage = 'android/images/check.png';
        }
    });

Problem: The toggle (check/uncheck) works perfectly fine on the Android emulator (actually it works fine right out of the box on emulator, even without the custom image) but it fails to work (fails to display the row.rightImage) on device in any case.

Any help is appreciated.

Upvotes: 0

Views: 1327

Answers (2)

JV.
JV.

Reputation: 2698

I was able to make it work later.

within the for loop

var row = Titanium.UI.createTableViewRow({
    //I was dealing with contacts
    title : contacts[i].fullName + ", "+ contacts[i].phone.mobile[j], 
    rightImage : 'images/blank.png'
    });
row.addEventListener('click', function(e) {
    if(e.row.getHasCheck()){
        e.row.setHasCheck(false);
        e.row.setRightImage('images/blank.png');            
    } else {
        e.row.setHasCheck(true);
        e.row.setRightImage('images/check.png');            
    }
});
tableData.push(row);

not much change but the image paths.

Upvotes: 1

Anand
Anand

Reputation: 5332

Try this sample code to change the right image of a row

Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow();

var tableData = [];

for(var index = 1; index<= 10; index++)
{
    var row = Titanium.UI.createTableViewRow({
        title       : 'row '+ index, 
        rightImage  : 'images/blue.png'
    });


    tableData.push(row);
}
var table = Ti.UI.createTableView({
    data: tableData
});

table.addEventListener('click', function(e){
        image = 'images/black.png';
        e.source.setRightImage(image);
});
win.add(table);

win.open();

NOTE: I've added the eventListener to the tableView instead of row.

Upvotes: 1

Related Questions