[Resolved] Help with tableView and tables!?#%

I’m trying to add one icon and one label to each of the tableView rows but instead of that I get att 5 Icons and labels in every cell on top of each other. What am I doing wrong?

going crazy…
Thanks
/C

[code]

local function onRowRender( event )
local row = event.target
local rowGroup = event.view

local iconTbl = {“firstIcon.png”, “secondIcon.png”,“thirdIcon.png”, “fourthIcon.png”, “fifthIcon.png”}
local labelTbl = {“first”, “second”, “third”, “fourth”, “fifth”}
local cellIcon = {}
local cellText = {}

local cellBg = display.newImageRect(rowGroup, “tableViewCellBg.png”, 320, 36);
cellBg:setReferencePoint(display.TopLeftReferencePoint);
cellBg.x = 0;
cellBg.y = 0;

for i = 1, #iconTbl do
cellIcon[i] = display.newImageRect(rowGroup, iconTbl[i], 18, 18);
cellIcon[i]:setReferencePoint(display.CenterLeftReferencePoint);
cellIcon[i].x = 10;
cellIcon[i].y = cellBg.height * 0.5;
end

for i = 1, #labelTbl do
cellText[i] = display.newEmbossedText(rowGroup, labelTbl[i], 0, 0, “Helvetica”, 16 )
cellText[i]:setReferencePoint( display.CenterLeftReferencePoint);
cellText[i].x = 38;
cellText[i].y = cellBg.height * 0.5;
cellText[i]:setTextColor(158, 162, 166, 255);
end

end
[/code] [import]uid: 65840 topic_id: 26312 reply_id: 326312[/import]

Fixed it.
:slight_smile: [import]uid: 65840 topic_id: 26312 reply_id: 106686[/import]

If you felt like posting your solutions for others that would be awesome :wink:

Either way, well done on fixing it so quickly - marking as resolved :slight_smile: [import]uid: 52491 topic_id: 26312 reply_id: 106701[/import]

yes please post your solution. I’m still learning and it really helps,
Cheers! [import]uid: 142733 topic_id: 26312 reply_id: 108505[/import]

Hi

Here’s how I solved it…

[code]

for i = 1, 5 do
– onRender listener for the tableView
local function onRowRender( event )
local row = event.target
local rowGroup = event.view
local iconTbl = {“firstIcon.png”, “secondIcon.png”,“thirdIcon.png”, “fourthIcon.png”, “fifthIcon.png”}
local labelTbl = {“first”, “second”, “third”, “fourth”, “fifth”}
local cellIcon = display.newImageRect(rowGroup, iconTbl[i], 18, 18);
cellIcon:setReferencePoint(display.CenterLeftReferencePoint);
cellIcon.x = 10;
cellIcon.y = 22;

local cellText = display.newText(rowGroup, labelTbl[i], 0, 0, “Arial”, 18)
cellText:setReferencePoint(display.CenterLeftReferencePoint);
cellText.x = 44;
cellText.y = 22;
cellText:setTextColor(123, 123, 123, 255);

end
[/code] [import]uid: 65840 topic_id: 26312 reply_id: 116363[/import]

Hey Cindy - thanks so much for sharing! Could really help others :slight_smile: [import]uid: 52491 topic_id: 26312 reply_id: 116419[/import]