Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11502] Android: TableView - Application crashes when adding a TableViewSection with headerView

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-10-30T17:22:35.000+0000
Affected Version/sRelease 2.1.3
Fix Version/sRelease 3.0.0, Release 3.1.0, 2012 Sprint 22 Core, 2012 Sprint 22
ComponentsAndroid
LabelsAndroid, TableView, TableViewSection, core, module_tableview, notable, qe-review, qe-testadded, triage
ReporterLucian Pacurar
AssigneeAllen Yeung
Created2012-10-04T11:08:02.000+0000
Updated2012-12-20T00:09:55.000+0000

Description

Problem

I have a fairly simple TableView in my app which crashes only when compiled with SDK 2.1.3. Inside the DDMS log attached you can find the exception thrown. The cause of the crash seems to be the headerView of the TableViewSection. Using the following test case the app crashes in the Android Emulators 4.0.3 and 4.1 on both WVGA800 and WXGA720 screen, but inside my app this code crashes only when ran on the WXGA720 screen.

Test case

var self = Ti.UI.createWindow({
		backgroundColor: "#ffffff",
		tabBarHidden: true
	});

var tableViewData = [];
	
var tableView = Ti.UI.createTableView({
	style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
});

self.add(tableView);

var headerView = Ti.UI.createView({
	height: 90,
	borderColor: 'transparent',
	borderWidth: 0,
});

var headerImageContainer = Ti.UI.createView({
	left: 19,
	height: 64,
	width: 64
});
	
headerImageContainer.add(Ti.UI.createView({
	backgroundImage: '/images/person.png',
	width: 64,
	height: 64,
	borderColor: '#a9a9a9',
	borderRadius: 4,
	borderWidth: 1,
	
}));

headerView.add(headerImageContainer);

tableViewData.push(Ti.UI.createTableViewSection({
	headerView: headerView,
}));

tableView.data = tableViewData;

self.add(tableView);

self.open();

Attachments

FileDateSize
crash log.txt2012-10-04T11:08:02.000+000010176

Comments

  1. Karl Rowley 2012-10-16

    When these two lines of Javascript code are removed, there is no failure: borderColor: 'transparent', borderWidth: 0, This is the first place I see a problem: Thread [<1> main] (Suspended (exception IllegalStateException)) ListView.layoutChildren() line: 1662 ListView(AbsListView).onLayout(boolean, int, int, int, int) line: 1147 ListView(View).layout(int, int, int, int) line: 7035 TiTableView(FrameLayout).onLayout(boolean, int, int, int, int) line: 333 TiTableView.onLayout(boolean, int, int, int, int) line: 555 TiTableView(View).layout(int, int, int, int) line: 7035 TiCompositeLayout.onLayout(boolean, int, int, int, int) line: 583 TiCompositeLayout(View).layout(int, int, int, int) line: 7035 TiCompositeLayout.onLayout(boolean, int, int, int, int) line: 583 TiCompositeLayout(View).layout(int, int, int, int) line: 7035 FrameLayout.onLayout(boolean, int, int, int, int) line: 333 FrameLayout(View).layout(int, int, int, int) line: 7035 LinearLayout.setChildFrame(View, int, int, int, int) line: 1249 LinearLayout.layoutVertical() line: 1125 LinearLayout.onLayout(boolean, int, int, int, int) line: 1042 LinearLayout(View).layout(int, int, int, int) line: 7035 PhoneWindow$DecorView(FrameLayout).onLayout(boolean, int, int, int, int) line: 333 PhoneWindow$DecorView(View).layout(int, int, int, int) line: 7035 ViewRoot.performTraversals() line: 1045 ViewRoot.handleMessage(Message) line: 1727 ViewRoot(Handler).dispatchMessage(Message) line: 99 Looper.loop() line: 123 ActivityThread.main(String[]) line: 4627 Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method] Method.invoke(Object, Object...) line: 521 ZygoteInit$MethodAndArgsCaller.run() line: 868 ZygoteInit.main(String[]) line: 626 NativeStart.main(String[]) line: not available [native method]
  2. Karl Rowley 2012-10-17

    Someone in the Core Team needs to look at this ticket
  3. Allen Yeung 2012-10-26

    Updated test case:
       var self = Ti.UI.createWindow({
       	backgroundColor : "#ffffff",
       	tabBarHidden : true
       });
       
       var tableViewData = [];
       
       var tableView = Ti.UI.createTableView({
       	// style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
       });
       
       self.add(tableView);
       
       var headerView = Ti.UI.createView({
       	height : 90,
       	borderColor : 'green',
       	borderWidth : 5,
       	backgroundColor : 'red'
       });
       
       var headerImageContainer = Ti.UI.createView({
       	left : 19,
       	height : 64,
       	width : 64,
       	backgroundColor : 'blue'
       });
       
       headerImageContainer.add(Ti.UI.createView({
       	backgroundColor : 'yellow',
       	width : 64,
       	height : 64,
       	borderColor : '#a9a9a9',
       	borderRadius : 4,
       	borderWidth : 1,
       }));
       
       headerView.add(headerImageContainer);
       
       tableViewData.push(Ti.UI.createTableViewSection({
       	headerView : headerView,
       }));
       
       tableView.data = tableViewData;
       
       self.add(tableView);
       
       self.open();
       
    Expected Results: There should be a red view with a green border for the row. Inside the red view, there is a yellow view.
  4. Allen Yeung 2012-10-26

    PR Ready: https://github.com/appcelerator/titanium_mobile/pull/3333
  5. Max Stepanov 2012-11-21

    3_0_X PR https://github.com/appcelerator/titanium_mobile/pull/3468
  6. Tamila Smolich 2012-12-04

    Closing as fixed. Tested on: Titanium Studio, build: 3.0.0.201211301903 Titanium SDK, builds: 3.0.0.v20121130200208; 3.1.0.v20121203181001 Devices: Samsung Galaxy S III (4.0.4)

JSON Source