Problem Description
In the attempt of creating a function that will remove all the elements inside a view or window, we are getting a different behavior between android and ios, where in android, if you have a window with several attached elements, it will say that there is no children.
Actual Results
There is no children attached to the window, even if there are.
Expected results
The same behavior than in iOS.
Test Case
1. Create mobile project.
2. Paste this into app.js
var win = Ti.UI.createWindow();
var view = Ti.UI.createView();
var label = Ti.UI.createLabel();
var label2 = Ti.UI.createLabel();
var image = Ti.UI.createImageView({
url:'KS_nav_ui.png',
});
var view2 = Ti.UI.createView();
view2.add(label);
view2.add(label2)
view.add(view2);
view.add(image);
win.add(view);
win.open();
function do_clean(e,c){
clean(c);
e.remove(c);
Ti.API.info( 'Deleted child at do_clean' );
return;
}
function clean(e){
Ti.API.info( 'Number of children: ' + e.children.length );
if(e.children){
for(var i = 0; i<e.children.length;i++){
do_clean(e, e.children[0]);
}
} else {
return;
}
}
clean(win);
3. Run this in ios, check the logs.
4. Run this in Android, check the logs.
HD Discussion
http://support-admin.appcelerator.com/display/APP-428357
Extra info
This is an attempt to do a cleaning of any window, view, tableview, etc.
This issue is related to TIMOB-7482
Btw, here is what does not work on Android: https://gist.github.com/2867975 For some reason, "_children" property does what "children" does in case of a window. "children" property on the other hand does nothing.
Updated test case:
Expected results: In both iOS and android, we should return something like
Actual result: In android, we get a single "Number of children: 0" and that's it.
Environment used for verification - Tested with Titanium SDK: 2.1.1.v20120716180600 Tested with Titanium Studio: 2.1.1.201207161421 Device - Android Emulator 2.3.3 Machine OS - MAC 10.7.3
Reopening to fix labels.
Updated labels.
Reopening issue to update labels
Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4967