I just wanted to make a note of this, just in case anyone else needs it.
When removing a view that has been previously added to a scrollable view, currently on android it is very important to remove the views that exist after it in the index BEFORE removing the view itself, otherwise you will experience an out of bounds index error. Once the view you want to remove is gone, add those that you removed back to the view index.
For example, if you have view0,view1,view2,view3,view4,view5 added to your scrollableView and you want to remove view3, then keep to the following sequence:
removeView: view5, view4, view3 addView: view4, view5
I will confer with the Ti devs to determine whether this is expected behaviour, and report back accordingly.
This is a test for Hal at Hal's request
Another test. Please ignore.
Even though this ticket shows the bug has been fixed. There still is a bug.
If you have the scrollableView selected on the view that you remove, then on Android it will remove the view, but not replace it.. It should scroll either to the previous or last view.
You can manually call scrollToView to fix this.. but, when there's only 2 views left, and you remove one of those. Then it becomes stuck on an empty view. There is no way of getting back to the last remaining view and the scrollToView does nothing (as you can test in the code below) and the scroll event does not fire either.
This works fine on iPhone, it' just Android that has the issue.
I'm testing on Titanium 1.6.1 and Android Api's 2.2
Sample code with 2 views and a scrollable view:
To test this. Manually scroll the view to "View 1" the green one. Then click on the button: "Remove View 1"
Expected result: The view gets removed and it scrolls back to view0. (this happens on iPhone)
On Android: The scrollableView remains blank, and there is no way to get back to view0.