Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15913] Android: Ti.UI.Switch in TableViewRow with className fires change event when scrolled onto screen

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.1.3
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, defect, reprod
ReporterJason Robb
AssigneeUnknown
Created2013-12-05T02:19:20.000+0000
Updated2018-02-28T20:03:57.000+0000

Description

Problem Description

When an instance of Ti.UI.Switch exists in Ti.UI.TableViewRows with a className attribute set and enough rows are present in the table that they scroll all the way off the screen, some of the switches will fire 'change' events as they scroll on and off the screen.

Steps to reproduce

Create a new mobile project

paste this code into app.js

var window = Ti.UI.createWindow({
  backgroundColor: '#FFF'
});
var tableView = Ti.UI.createTableView();
var data = [];

for (var i=0; i<50; i++) {
  var row = Ti.UI.createTableViewRow({
    height: 100,
    className: 'myRow'
  });
  var mySwitch = Ti.UI.createSwitch({
    value: i % 3 == 0,
    number: i
  });
  mySwitch.addEventListener('change', function(e) {
    alert("Switch " + e.source.number + " was changed!");
  });
  row.add(Ti.UI.createLabel({
    text: i,
    left: 20,
    color: '#000'
  }));
  row.add(mySwitch);
  data.push(row);
}

tableView.setData(data);
window.add(tableView);
window.open();

run this in device

just scroll down

Comments

  1. Lee Morris 2017-06-27

    I am able to reproduce this issue with the following environment; Pixel (7.1) Studio 4.9.0.201705302345 Ti SDK 6.1.1.v20170623141152 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131

JSON Source