Thanks Rob,
There’s something strange with this code, I get an error at line 31 and I’m so confused since that is the print function that is commented out so nothing shows up in the Simulator.
I’m using the tabBar sample as my starting point.
screen2.lua
module(..., package.seeall)
local json = require("json")
function new()
local g = display.newGroup()
local newToolbar = newToolbar
local newButton = newButton
local newTableView = newTableView
local myNavBar;
local myBackBtn;
local background;
local entries;
local category;
local myTableView;
-- Forward references for downloading of the json file.
local networkListener;
local fileName = "gigs.json";
local fileURL = "";
entries = json.decode(myData)
print(entries)
category = ""
local j = 1
for i = 1, #entries do
if entries[i].month == category then
--print("Adding item " .. entries[i].title)
itemData[j] = {}
itemData[j].icon = itemIcon;
itemData[j].title = {
label = entries[i].place,
font = "Helvetica-Bold",
size = 18,
color = { 0, 0, 0 }, -- red, green, blue
left = 10,
top = 10
}
itemData[j].subtitle = {
label = entries[i].time .. " - " .. entries[i].admission,
font = "Helvetica",
size = 14,
color = { 150, 150, 150 },
left = 10,
top = 0
}
itemData[j].onRelease = onItemRelease
else
category = entries[i].month
itemdata[j].CategoryName = category
end
j = j + 1
end
local myTableView = newTableView
{
y = 64,
rowHeight = 61,
height = 384,
width = 320,
backgroundColor = "none",
bottomLineColor = {218, 230, 241},
rowColor = {231, 235, 237},
downColor = {218, 230, 241},
}
g:insert( myTableView.view )
myTableView:sync(itemData)
myNavBar = newToolbar ("Gigs")
g:insert(myNavBar.view)
function g:cleanUp()
-- Remove widgets.
display.remove(myNavBar);
myNavBar = nil;
display.remove(myTableView);
myTableView = nil;
-- Remove the entire group.
g:removeSelf();
g = nil;
print(" clean screen2!");
end
return g
end
gigs.json
[
{
"month": "October",
"date": "1st",
"place": "The Big Bar",
"time": "21.00",
"admission": "$20",
"description": "Only hot chicks allowed...",
"address": "21 Down Street"
},
{
"month": "October",
"date": "5th",
"place": "The Nice Bar",
"time": "22.00",
"admission": "$10",
"description": "Only hot chicks allowed...",
"address": "21 Nude Street"
},
{
"month": "October",
"date": "5th",
"place": "The Nice Bar",
"time": "22.00",
"admission": "$10",
"description": "Only hot chicks allowed...",
"address": "21 Nude Street"
},
{
"month": "October",
"date": "5th",
"place": "The Nice Bar",
"time": "22.00",
"admission": "$10",
"description": "Only hot chicks allowed...",
"address": "21 Nude Street"
},
{
"month": "October",
"date": "5th",
"place": "The Nice Bar",
"time": "22.00",
"admission": "$10",
"description": "Only hot chicks allowed...",
"address": "21 Nude Street"
},
{
"month": "October",
"date": "5th",
"place": "The Nice Bar",
"time": "22.00",
"admission": "$10",
"description": "Only hot chicks allowed...",
"address": "21 Nude Street"
},
{
"month": "November",
"date": "10th",
"place": "The Big Bar",
"time": "21.00",
"admission": "$20",
"description": "Only hot chicks allowed...",
"address": "21 Drive Street"
},
{
"month": "November",
"date": "10th",
"place": "The Big Bar",
"time": "21.00",
"admission": "$20",
"description": "Only hot chicks allowed...",
"address": "21 Drive Street"
},
{
"month": "November",
"date": "10th",
"place": "The Big Bar",
"time": "21.00",
"admission": "$20",
"description": "Only hot chicks allowed...",
"address": "21 Drive Street"
},
{
"month": "November",
"date": "10th",
"place": "The Big Bar",
"time": "21.00",
"admission": "$20",
"description": "Only hot chicks allowed...",
"address": "21 Drive Street"
},
{
"month": "November",
"date": "15th",
"place": "The Nice Bar",
"time": "22.00",
"admission": "$10",
"description": "Only hot chicks allowed...",
"address": "21 Jump Street"
}
]
[import]uid: 34126 topic_id: 13975 reply_id: 62059[/import]