Hi,
I’ve made a tableview, and the user can add to the list. The list is empty at first, but then if they press the “add” button, it takes them to a screen where they can enter into a textfield what they want to the row’s name to be. I store the input into a variable, and then I want to add that input into a new row. How can I do that?
I know that you have to change the onRowRender() function if you want the list to have already been populated:
local rowTitle local rowText if (row.isCategory) then if row.index == 1 then rowText = "CATEGORY 1" rowTitle = display.newText(row, rowText, 0, 0, globals.font.regular, 20) rowTitle.x = constants.leftPadding else rowText = "CATEGORY " .. row.index % 10 + 1 rowTitle = display.newText(row, rowText, 0, 0, globals.font.regular, 20) end else rowText = "Row" \<-- change that to change the first letter rowTitle = display.newText(row, rowText .. row.index, 0,0, globals.font.regular, 20) end
which will make the tableView have this (let’s just say I took the category part out):
-Row 2
-Row 3
-Row 4
-Row 5
-Row 6
-Row 7
etc.
But I want the list to be empty first. Then, by user input, be populated. So instead of Row 1, Row 2, Row 3, it would be:
-Walk the Dog
-Wash the car
-Water the plants
-Finish the Lord of the Rings
etc.
How can I insert specific text into each row of a tableView?