[TIMOB-4590] Android: putting a scrollView in a tableView crashes the app after scrolling
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2013-04-26T08:59:45.000+0000 |
Affected Version/s | Release 1.7.1, Release 1.8.2 |
Fix Version/s | 2013 Sprint 09 |
Components | Android |
Labels | api |
Reporter | Jon Alter |
Assignee | jithinpv |
Created | 2011-07-05T13:58:29.000+0000 |
Updated | 2013-11-07T19:03:28.000+0000 |
Description
If you put a ScrollView in a TableView it crashes when you scroll down and then back up to the ScrollView.
Step 1: run the code below.
Step 2: scroll down on the table view and then back up
Step 3: notice the app crash
var win = Titanium.UI.createWindow({
backgroundColor:'#000'
});
win.open();
var tableViewRows = [];
var scrollView = Titanium.UI.createScrollView({
contentWidth:500,
contentHeight:50,
top:10,
height:50,
width:230,
borderRadius:10,
backgroundColor:'#13386c'
});
var view1 = Ti.UI.createView({
backgroundColor:'#336699',
borderRadius:20,borderWidth:1,borderColor:'#336699',
width:40,
height:40,
left:10
});
scrollView.add(view1);
var l1 = Ti.UI.createLabel({
text:'1',
font:{fontSize:13},
color:'#fff',
width:'auto',
textAlign:'center',
height:'auto'
});
view1.add(l1);
var view2 = Ti.UI.createView({
backgroundColor:'#336699',
borderRadius:20,borderWidth:1,borderColor:'#336699',
width:40,
height:40,
left:60
});
scrollView.add(view2);
var l2 = Ti.UI.createLabel({
text:'2',
font:{fontSize:13},
color:'#fff',
width:'auto',
textAlign:'center',
height:'auto'
});
view2.add(l2);
var scrollViewRow = Ti.UI.createTableViewRow({
height: 'auto',
className: 'scrollrow'
});
scrollViewRow.add(scrollView);
tableViewRows.push(scrollViewRow);
for(var i = 0; i < 40; i++)
{
var row = Ti.UI.createTableViewRow({
title: 'some text',
height: 'auto',
className: 'row'
});
tableViewRows.push(row);
}
var tableView = Titanium.UI.createTableView({
data: tableViewRows
});
win.add(tableView);
W/dalvikvm( 312): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/TiUncaughtHandler( 312): (main) [238,55548] Sending event: exception on thread: main msg:java.lang.IllegalStateException: Ambiguous Z-Order; Titanium 1.7.1,2011/06/21 14:28,293a6d
E/TiUncaughtHandler( 312): java.lang.IllegalStateException: Ambiguous Z-Order
This bug is still occuring and can still be reproduced in TiSDK 1.8.1
I also notice a crash in a very similar scenario with TiSDK 1.8.2 on Nexus S with Android 2.3.6. You don't even need to scroll, just follow these steps: Step 1. Start app. Step 2. Tap tab 2. Step 3. Tap tab 1. Step 4. Notice the app crash. *app.js*
and *scrollView_in_tableView.js*
Mixing scrollview and tableview should be discouraged in general. In iOS, Apple [advises](https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIWebView_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UIWebView): {quote} *Important* You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled. {quote} Perhaps for similar reasons Android OS has issues and this may be deeper than Titanium.
Mixing scrollview and tableviw is strongly discouraged in Titanium for the reason explained in the last comment.
Reducing the priority as this usage is discouraged in the documentation.
cannot reproduce Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Android Emulator: Android SDK version: 2.2
Verified with above apps but could not reproduce this issue. Tested with Appcelerator Studio build: 3.1.1.201305072102 Titanium SDK version: 3.1.0 (GA), 3.1.1.v20130508001914 Android Emulator: Android SDK version: 2.3 Device: Samsung Galaxy (v2.3.6) Hence closing this issue.