Director with list view

Hi everyone,

I am trying to put a list view in one of my screens while using the director class. Has anyone been able to successfully do it? What I am doing is pulling up a very simple list view after pressing a button. Does anyone have a very basic sample of how they accomplished this? Thanks in advance.

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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

Thanks so much mpotter. Being so new at this I'm finding that there are a lot of samples on how to do the more complicated things and not so much help on how to do the more straight forward. Appreciate your help.

@MPotter - can you put together a downloadable/emailable sample that incorporates the list view (acting like a menu) wrapped in director that then loads other screens?

Much like the director class sample but instead of the buttons on screen1.lua have the scrolling list view.

- davey (davey at a3mg dot com)

views:1647 update:2011/10/13 9:25:17
corona forums © 2003-2011