Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-11762

Android: can't update image inside a TableViewRow

    Details

      Description

      Problem description

      Trying to update an image inside a TableViewRow works only a couple of time; after that, the image properties can be changed (e.g. right), but not the image itself.

      Steps to reproduce

      Use the following code:

      Ti.UI.backgroundColor = '#e3e8ee';
       
      var win = Ti.UI.createWindow();
      var table = Ti.UI.createTableView();
      var rows = [];
       
      for (var i = 1; i <= 50; i++) {
      	var row = Ti.UI.createTableViewRow({
      		height	: '40dp'
      	});
       
      	var label = Ti.UI.createLabel({
      		height	: Ti.UI.SIZE,
      		left	: '5dp',
      		text	: 'Row ' + i,
      		top		: '5dp',
      		width	: Ti.UI.SIZE
      	});
      	row.text = label;
      	row.add(row.text);
       
      	var image = Ti.UI.createImageView({
      		height	: '28dp',
      		image	: '/images/radiobutton_off.png',
      		right	: '0dp',
      		top		: '5dp',
      		width	: '34dp'
      	});
      	row.image = image;
      	row.add(row.image);
      	
      	rows.push(row);
      }
       
      table.setData(rows);
       
      win.add(table);
      win.open();
       
      setActive(0);
       
       
      function setActive (_index) {
      	for (var i = 0; i < table.data[0].rows.length; i++) {
      		if (i === _index) {
      		    table.data[0].rows[i].text.text = "Row " + i + " ON";
      			table.data[0].rows[i].image.image = '/images/radiobutton_on.png';
      			table.data[0].rows[i].image.right = '50dp';
      		}
      		else {
      		    table.data[0].rows[i].text.text = "Row " + i;
      			table.data[0].rows[i].image.image = '/images/radiobutton_off.png';
      			table.data[0].rows[i].image.right = '0dp';
      		}
      	}
      }
       
      table.addEventListener('click', function (e) {
      	setActive(e.index);
      });
      

      Running the code on Android, you can notice how automatically the first row changes: the label text shows "ON", the image is moved 30dp from the right and the image itself changes to the active button.

      Clicking a row, the process works again on that row.

      Click the second time and everything changes, but the image.

      Note

      I tried SDK from 2.1.3 to 3.0.0, same behavior. I also tried adding a className to the rows (both same class for all the rows, or a different one per row), nothing changes.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hpham Hieu Pham
                Reporter:
                dcassenti Davide Cassenti
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-14943
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration