Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8706] Android: TableView scroll event is also triggered for other events.

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-07-10T05:00:56.000+0000
Affected Version/sRelease 2.1.0, Release 1.8.2
Fix Version/sRelease 2.1.0, Sprint 2012-09 API
ComponentsAndroid
LabelsSupportTeam, api, module_tableview, qe-testadded
ReporterFederico Casali
AssigneeVishal Duggal
Created2012-04-12T15:56:25.000+0000
Updated2013-12-10T06:13:00.000+0000

Description

Problem description

tableView 'scroll' event is triggered also when just opening the tableView, clicking on a row or opening the keyboard.

Steps to reproduce

- Create a tableView and set an event listener associated to the 'scroll' event Result: function is called when opening the window, clicking on a row in the tableView and other events not relative to scroll (see code sample - also when clicking on a textField and opening the keyboard) Same code works as expected on iOS.
var win = Ti.UI.createWindow({
	title:'pippo',
	backgroundColor:'gray'
});

var search = Titanium.UI.createTextField({ 
	// color:'#336699', 
	top:5,
	width:400,
	left:10, 
	hintText:'Search for ...',
	borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, keyboardType:Titanium.UI.KEYBOARD_DEFAULT, returnKeyType:Titanium.UI.RETURNKEY_DEFAULT
});

win.add(search);

var data = [];
var autocomplete_table = Titanium.UI.createTableView({ 
	scrollable: true, 
	top: 170,
	bottom:0,
	backgroundColor:'white',
	data:data
});

var row = Ti.UI.createTableViewRow({
	title:'test'
});
data.push(row);

var autocomplete_table = Titanium.UI.createTableView({ 
	scrollable: true, 
	top: 170,
	bottom:0,
	backgroundColor:'white',
	data:data
});


win.add(autocomplete_table);

autocomplete_table.addEventListener('scroll', function(e) { 
	search.blur(); 
	alert('triggered!')
});

win.open();

Additional notes

Customer ticket associated: http://support-admin.appcelerator.com/display/APP-613444

Comments

  1. Vishal Duggal 2012-04-23

    Test code
       var win = Ti.UI.createWindow({
           title:'pippo',
           backgroundColor:'gray'
       });
        
       var search = Titanium.UI.createTextField({ 
           // color:'#336699', 
           top:5,
           width:400,
           left:10, 
           hintText:'Search for ...',
           borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, keyboardType:Titanium.UI.KEYBOARD_DEFAULT, returnKeyType:Titanium.UI.RETURNKEY_DEFAULT
       });
        
       win.add(search);
        
       var data = [];
       var autocomplete_table = Titanium.UI.createTableView({ 
           scrollable: true, 
           top: 170,
           bottom:0,
           backgroundColor:'white',
           data:data
       });
       
       for (i=0;i<50;i++)
       { 
       	var row = Ti.UI.createTableViewRow({
           	title:'test' + i
       	});
       	data.push(row);
       }
        
       var autocomplete_table = Titanium.UI.createTableView({ 
           scrollable: true, 
           top: 170,
           bottom:0,
           backgroundColor:'white',
           data:data
       });
        
        
       win.add(autocomplete_table);
        
       autocomplete_table.addEventListener('scroll', function(e) { 
           search.blur(); 
           Ti.API.info("scroll fired");
       });
        
       win.open();
       
  2. Vishal Duggal 2012-04-23

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/2052
  3. Payminder Singh 2012-06-23

    Titanium Studio: 2.1.0.201206221045 & 2.0.2 Mobile SDK: 2.1.0.v20120622174154 OS: X Lion Device: Samsung Galaxy Can't reproduce. Scroll event get fired only by scrolling, tap on text area or on rows doen't fired scrolling event.
  4. Neha Chhabra 2012-07-10

    Reopening to update labels.
  5. Shameer Jan 2013-12-10

    Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/5003

JSON Source