Instead of posting the entire code, here’s the link of what I’m playing with:
http://developer.coronalabs.com/content/list-view-2
The listView is a great tool, and probably the most necessary part of displaying data for me.
I can see that when the List Item is touched, a new screen is transitioned, while the backBtn is transitioned into view - along with a small text message displaying which List Item was touched in the array.
Here’s the thing, I want to detect a preset ID, or Name, or Database ID (if the list item is populated from a database).
lines 34 - 49
function listButtonRelease( event )
self = event.target
local id = self.id
print(self.id)
detailScreenText.text = "You tapped item ".. 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
I see print(self.id) as the identifying feature in the touch event. And that’s the sorted number in the list.
How do I pass my own specific ID for each List Item, so I can look up specific data from the database?
I imagine it’s possible from within the table data provided:
-- setup some data
local data = {}
for i=1, 20 do
data[i] = {}
data[i].title = "List item ".. i
local c = math.modf(i/5)
data[i].category = "Category ".. c + 1
end
[import]uid: 154122 topic_id: 28668 reply_id: 328668[/import]