ListView Help - detailScreen

Hi Folks,

I’m making an application that requires more information on the detailScreen of the List View.

Could someone show me how to add more fields to the detailView from data pulled from my sqlite table please?

I’ve tried for a while to get this to work but keep getting errors and going in circles.

[code]

– Abstract: Tab Bar sample app, example content screen

– Version: 1.0

– Sample code is MIT licensed, see http://developer.anscamobile.com/code/license
– Copyright © 2010 ANSCA Inc. All Rights Reserved.

– This file is used to display the corresponding screen content when the user clicks the tab bar.

module(…, package.seeall)
function new()
local g = display.newGroup()

–initial values
local screenOffsetW, screenOffsetH = display.contentWidth - display.viewableContentWidth, display.contentHeight - display.viewableContentHeight

local myList, backBtn, detailScreenText, data
–start DB Connection

–Open database and set the path to the same folder
local path = system.pathForFile(“game.sqlite”, system.TemporaryDirectory)
db = sqlite3.open( path )
–setup a destination for the list items
local detailScreen = display.newGroup()

local detailBg = display.newRect(0,0,display.contentWidth,display.contentHeight-50)
detailBg:setFillColor(255,255,255)
detailScreen:insert(detailBg)
detailScreenText = display.newText(“You tapped item”, 0, 0, native.systemFontBold, 24)
detailScreenText:setTextColor(0, 0, 0)
detailScreen:insert(detailScreenText)
detailScreenText.x = math.floor(display.contentWidth/2)
detailScreenText.y = math.floor(60)
detailScreen.x = display.contentWidth
g:insert(detailScreen)
–setup functions to execute on touch of the list view items
function listButtonRelease( event )
self = event.target
local id = self.id
print(self.id)

detailScreenText.text = "PS3 Game "… self.id
transition.to(myList, {time=400, x=display.contentWidth*-1, transition=easing.outExpo })
transition.to(detailScreen, {time=400, x=0, transition=easing.outExpo })
transition.to(backBtn, {time=400, x=math.floor(backBtn.width/2) + screenOffsetW*.5 + 6, transition=easing.outExpo })
transition.to(backBtn, {time=400, alpha=1 })

delta, velocity = 0, 0
end

function backBtnRelease( event )
print(“back button released”)
transition.to(myList, {time=400, x=0, transition=easing.outExpo })
transition.to(detailScreen, {time=400, x=display.contentWidth, transition=easing.outExpo })
transition.to(backBtn, {time=400, x=math.floor(backBtn.width/2)+backBtn.width, transition=easing.outExpo })
transition.to(backBtn, {time=400, alpha=0 })

delta, velocity = 0, 0
end
–test test

– Open Array
local data = {}
local i = 1

–Begin SQL
local sql = “SELECT * FROM games WHERE platform = 3 ORDER BY eu_rel ASC”

for row in db:nrows(sql) do

– setup some data
data[i] = {}
data[i].title = row.title
data[i].cover = row.cover
data[i].subtitle = row.eu_rel
i = i +1
end
local topBoundary = display.screenOriginY + 40
local bottomBoundary = display.screenOriginY + 0

– create the list of items
myList = tableView.newList{
data=data,
default=“listItemBg.png”,
over=“listItemBg_over.png”,
onRelease=listButtonRelease,
top=topBoundary,
bottom=bottomBoundary,
backgroundColor={ 255, 255, 255 },

callback=function( row )
local gg = display.newGroup()

local title = display.newText( row.title, 0, 0, native.systemFontBold, 14 )
title:setTextColor(0, 0, 0)
–title:setTextColor(255, 255, 255)
gg:insert(title)
title.x = title.width /2 + 10
title.y = 30

local subtitle = display.newText( row.subtitle, 0, 0, native.systemFont, 12 )
subtitle:setTextColor(80,80,80)
–subtitle:setTextColor(180,180,180)
gg:insert(subtitle)
subtitle.x = subtitle.width /2 + 10
subtitle.y = title.y + title.height + 6

return gg
end

}

g:insert(myList)

myList:toBack()

local function scrollToTop()
myList:scrollTo(topBoundary-1)
end

–Setup the nav bar
local navBar = ui.newButton{
default = “navBar.png”,
onRelease = scrollToTop
}
navBar.x = display.contentWidth*.5
navBar.y = math.floor(display.screenOriginY + navBar.height*0.5)

local navHeader = display.newText(“PS3 Games”, 0, 0, native.systemFontBold, 16)
navHeader:setTextColor(255, 255, 255)
navHeader.x = display.contentWidth*.5
navHeader.y = navBar.y

–Setup the back button
backBtn = ui.newButton{
default = “backButton.png”,
over = “backButton_over.png”,
onRelease = backBtnRelease
}
backBtn.x = math.floor(backBtn.width/2) + backBtn.width + screenOffsetW
backBtn.y = navBar.y
backBtn.alpha = 0
function g:cleanUp()
g:removeSelf()
end

return g
end
[/code] [import]uid: 97707 topic_id: 16799 reply_id: 316799[/import]

What error are you getting when you try to run that? [import]uid: 18554 topic_id: 16799 reply_id: 63545[/import]

@Developer79 - Try using Director class…It will make you life easier…

  1. ListView - Create the list with values.
  2. OnListButtonRelease - call director class and change the scene. You can pass selected row value to the next scene e.g director:changeScene(“DetailScreen”,{data=“selectedRowValue”})
  3. In detail screen - Write your logic to call sql code and load more details.

Check out director class here:
http://developer.anscamobile.com/code/director-class-10

Let us know if it goes… [import]uid: 84539 topic_id: 16799 reply_id: 63584[/import]

Using Director class would work of course, but seems to unnecessarily complicate what he’s trying to do. If he just needs the ListView to function as intended but with more content in the detailScreen it should work fine.

My app does this and the code looks similar enough to yours, so let me know what error you’re getting. [import]uid: 18554 topic_id: 16799 reply_id: 63606[/import]

Hi,

Is this issue solved?

[import]uid: 115996 topic_id: 16799 reply_id: 103224[/import]

I’m having the same issue. Can someone give an actual working code example of this in action please?
[import]uid: 154706 topic_id: 16799 reply_id: 127776[/import]

I’m actually trying to get the listview.lua to transition back to a previous Director.lua scene.
Once I transition from the Director.lua scene to a listview.lua, I can’t get it the back button to transition back to the Director.lua scene. It wants to stop at mylist. [import]uid: 154706 topic_id: 16799 reply_id: 127777[/import]

I’m having the same issue. Can someone give an actual working code example of this in action please?
[import]uid: 154706 topic_id: 16799 reply_id: 127776[/import]

I’m actually trying to get the listview.lua to transition back to a previous Director.lua scene.
Once I transition from the Director.lua scene to a listview.lua, I can’t get it the back button to transition back to the Director.lua scene. It wants to stop at mylist. [import]uid: 154706 topic_id: 16799 reply_id: 127777[/import]