Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14018] Android: 'longpress' on tableView with headerView but no headerTitle returns incorrect index and might lead to a crash

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionDuplicate
Resolution Date2013-05-29T20:53:47.000+0000
Affected Version/sRelease 3.2.0
Fix Version/sn/a
Componentsn/a
Labelsregression
ReporterJick Steen
AssigneeIngo Muschenetz
Created2013-05-29T11:14:20.000+0000
Updated2017-03-21T22:56:35.000+0000

Description

I've already added a comment on TIMOB-12114 but I do not have the permission to reopen it because it is already resolved. The app is still crashing on 3.2.0.v20130522115134 build if you remove the headerTitle. Tried it on a Samsung Galaxy S2 with Android 4.1.2. Looks like it is crashing even if you haven't added a longpress event listener. That means once a user does a longpress on any row, the Android app crashes. Link to Q&A discussion: http://developer.appcelerator.com/question/152977/android-longpress-on-tableview-with-headerview-returns-incorrect-index-and-might-lead-to-a-crash Code to reproduce:
var _self = Ti.UI.createWindow({
	backgroundColor : '#fff',
	height : Ti.UI.FILL,
	width : Ti.UI.FILL
});
_self.open();

var table = Ti.UI.createTableView({
	//headerTitle : "title" // Remove to fix
});

var headerView = Ti.UI.createView({
	backgroundColor : '#444',
	visible : false,
	height : 0
});
var titleLabel = Ti.UI.createLabel({
	width : _self.width,
	textAlign : 'center',
	color : '#eee',
	text : "Title text"
});
headerView.add(titleLabel);
table.setHeaderView(headerView);

var row = Ti.UI.createTableViewRow({
	title : 'Press me long'
});
table.setData([row]);

_self.add(table);

table.addEventListener('click', function(e) {
	Ti.API.info("#### table - row " + e.index + " clicked")
});
table.addEventListener('longpress', function(e) {
	Ti.API.info("#### table - row " + e.index + " longpressed")
});

Comments

  1. Daniel Sefton 2013-05-29

    Tested and confirmed on Samsung Galaxy S2 Android 2.3.6 with latest 3.2 CI build. I will link the two issues.
  2. Ingo Muschenetz 2013-05-29

    Going to re-mark as a duplicate and reopened the old one.
  3. Lee Morris 2017-03-21

    Closing ticket as duplicate with reference to the above comments.

JSON Source