Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3378] Android: ScrollView.remove() doesn't really remove on android

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-01-03T18:04:40.000+0000
Affected Version/sRelease 1.6.2
Fix Version/sSprint 2011-43, Release 1.8.0.1
ComponentsAndroid
Labelsmodule_scrollview, qe-testadded
ReporterAlberto Berti
AssigneePing Wang
Created2011-04-15T03:43:31.000+0000
Updated2013-11-19T06:14:22.000+0000

Description

It seems to me that the remove() method on ScrollView doesn't do its job on Android (build 1.6.0+ from continous builds). Here is a test code where a button should be removed from the view when it's clicked:

var win = Titanium.UI.createWindow({  
    title:'Scrollview test window',
    backgroundColor:'#fff'
});

var scrollview = Ti.UI.createScrollView({layout: 'vertical'});

win.add(scrollview);

function onButtonClick(event){
    var button = event.source;
    var n = Ti.UI.createNotification({message: 'Removed button "' + button.title + '"'});
    n.duration = Ti.UI.NOTIFICATION_DURATION_LONG;
    button.removeEventListener('click', onButtonClick);
    scrollview.remove(button);
    n.show();
}

var i, button;
for (i = 0; i < 30; i++) {
    button = Ti.UI.createButton({title: String.format('Click to remove #%d', i)});
    button.addEventListener('click', onButtonClick);
    scrollview.add(button);
}

win.open();

I've attached a test project containing this code for you to enjoy.

Attachments

FileDateSize
Screen shot 2011-10-31 at 5.38.42 PM.png2011-10-31T16:50:30.000+00001136601
scrollviewtest.tgz2011-04-15T03:43:32.000+0000740522

Comments

  1. Paul Dowsett 2011-07-26

    I can confirm this on Titanium 1.7.1 (2011/06/17 00:13 293a6d...). Below is a simplified testcase:
       var win = Ti.UI.createWindow({
       	backgroundColor: 'blue'
       });
       
       var scrollView = Ti.UI.createScrollView({
       	layout: 'vertical'
       });
       
       var label = Ti.UI.createLabel({
       	text: 'Test',
       	top:20,
       	width: 300
       });
       
       var textField = Ti.UI.createTextField({
       	top:20,
       	width: 300
       });
       
       scrollView.add(label);
       scrollView.add(textField);
       
       win.add(scrollView);
       
       scrollView.addEventListener('click', function(){
       	scrollView.remove(textField);
       });
       
       win.open();
       
  2. Ivan Skugor 2011-08-11

    Workaround is to add components to "View" component, add that "View" component to "ScrollView" component and then remove components from "View" component. Anyway, I would really appreciate if this would be fixed soon. Thanks. :)
  3. Ping Wang 2011-10-31

    Just found another issue, maybe related to this bug. I ran the same test code on both iphone and android, and they have very different looks (see attachment [^Screen shot 2011-10-31 at 5.38.42 PM.png]).
       var win = Titanium.UI.createWindow({ backgroundColor:'#f0f0f0' });
       
       var parent = Ti.UI.createView({ width:150, height:150, top:0, left:0, borderColor:'red', borderWidth:3 });
       
       var greenView = Ti.UI.createScrollView({ width:100, height:100, top:0, left:0, borderColor:'green', borderWidth:1 });
       
       var child = Ti.UI.createView({ width:10, height:10, top:15, left:15, borderColor:'black', borderWidth:3 });
       
       var button1 = Ti.UI.createButton({ title:'remove from scrollview', top:150, left:0, width:200, height:40 });
       var button2 = Ti.UI.createButton({ title:'remove from view', top:200, left:0, width:200, height:40 });
       
       button1.addEventListener('click', function() { greenView.remove(child); });
       button2.addEventListener('click', function() { parent.remove(greenView); });
       win.add(parent);
       parent.add(greenView);
       greenView.add(child);
       win.add(button1);
       win.add(button2);
       win.open();
       
  4. Ping Wang 2011-11-02

    Fixed the ScrollView.remove() issue. The pull request is https://github.com/appcelerator/titanium_mobile/pull/616 . The issue that one code generates two different looks on iphone and android is not related to the remove() issue.
  5. Josh Roesslein 2011-11-10

    Pull request accepted.
  6. Ivan Skugor 2011-11-15

    Doesn't work with latest 1.8.0 build: Titanium SDK version: 1.8.0 (11/14/11 10:39 1012866...), using Rhino engine.
  7. Don Thorp 2011-11-15

    @Ivan, notice the fixVersion says it was committed to "Release 1.8.0.1" that's on master. It was not committed to the 1_8_X ("Release 1.8.0") branch. Try it on 1.8.0.1 please.
  8. Eric Merriman 2011-12-07

    Verified fixed with SDK 1.8.0.1.v20111207112258 in both Rhino and V8 on Nexus S 2.3.6 and Droid 3 2.3.4 using Titanium Studio, build: 1.0.7.201112061404.
  9. Michael Pettiford 2012-01-03

    Reopening/closing to add labels
  10. jithinpv 2013-11-19

    anvil test case added PR Link: https://github.com/appcelerator/titanium_mobile/pull/4958

JSON Source