Yes, I do this a lot in my app. In your “Screen2” (the one with the list view), your new() routine would be something like this:
[lua]function new()
local group = display.newGroup()
local back = display.newRect( 0, 0, display.contentWidth, display.contentHeight)
back:setFillColor( 0,0,0)
group:insert(back)
local listData = {“Line1”,“Line2”,“Line3”,“whatever”}
local list = tableView.newList{
data = listData,
callback = function(row, id)
local t = display.newText( row, 0, 0, nil, size)
t:setTextColor(255,255,255)
return t
end
}
group:insert(list)
local function touchHandler( event )
if event.phase == “ended” then
director:changeScene(“mainForm”,“moveFromLeft”)
return true
end
end
back:addEventListener(“touch”, touchHandler)
return group
end[/lua]
However, also see my post here: http://developer.anscamobile.com/forum/2011/02/16/memory-leak-list-views-tableviewlua regarding a memory leak in the List View that causes trouble with Director.
Use the new Director 1.2 and then make your “list” variable local to the Screen2 module (remove the “local” keyword in front of “list” in the new() routine) and then add a cleanup function:
[lua]function clean()
if list then list:cleanUp(); list = nil end
end[/lua]
This will properly clean up the list when you exit this screen. [import]uid: 12529 topic_id: 6729 reply_id: 23465[/import]