Hi all,
New here so go easy 
I have the following code in my app that creates a list of artists and on each list item is a button. The button is either “Add” or “Remove” depending on whether the user has previously added them. onRelease I add or remove the item. What I’d then like to do is toggle the button, so the “Add” becomes “Remove” and vice versa. I’m just not sure how I access display objects by ID. If I just try removing “addToScheduleBtn” and creating a new “removeFromBtn” it only effects the last button on the list.
Any help is appreciated.
[lua]atozArtistList = tableView5.newList{
data=atozArtistData,
default=“listItemBg.png”,
over=“listItemBg_over.png”,
onRelease=atozArtistListButtonRelease,
top=topBoundary,
bottom=bottomBoundary,
callback=function(row)
local g = display.newGroup()
local title = display.newText( row.title, 0, 0, “Helvetica”, 16 )
title:setTextColor(0,0,0)
g:insert(title)
title.x = title.width*0.5 + 12
title.y = 28
local subtitle = display.newText( row.date … " - "…row.time, 0, 0, “Helvetica”, 14 )
subtitle:setTextColor(60,60,60)
g:insert(subtitle)
subtitle.x = subtitle.width*0.5 + 12
subtitle.y = title.y + title.height + 5
local subtitle2 = display.newText( row.venue_name, 0, 0, “Helvetica”, 14 )
subtitle2:setTextColor(60,60,60)
g:insert(subtitle2)
subtitle2.x = subtitle2.width*0.5 + 12
subtitle2.y = title.y + title.height + 25
print(row.scheduled)
if(row.scheduled == nil) then
addToScheduleBtn = ui.newButton{
default = “addButton.png”,
over = “addButton_over.png”,
onRelease =
function()
addToSchedule(row.id)
end,
id = “add”…row.id
}
addToScheduleBtn.x = display.contentWidth - 45
addToScheduleBtn.y = 50
addToScheduleBtn.alpha = 1
g:insert(addToScheduleBtn)
atozButtons[row.id] = addToScheduleBtn
else
removeFromScheduleBtn = ui.newButton{
default = “removeButton.png”,
over = “removeButton_over.png”,
onRelease =
function()
removeFromSchedule(row.id)
atozButtons[row.id] = nil
self:remove = nil
end
}
removeFromScheduleBtn.x = display.contentWidth - 45
removeFromScheduleBtn.y = 50
removeFromScheduleBtn.alpha = 1
g:insert(removeFromScheduleBtn)
atozButtons[row.id] = removeFromScheduleBtn
end
return g
end,
x=0
}
atozScreen:insert(atozArtistList)[/lua] [import]uid: 69057 topic_id: 11186 reply_id: 311186[/import]