[updated 2]
Okay, after making an app (on build 704) that uses lists, I wanted to upgrade to the latest build (759).
To test the update tableView widget, I made some simple test code to get familiar with it.
Problem? I can’t get it to work. The sample codes in the reference section of the website and the blog (addressing the post 704 changes to the tableView), simply don’t work.
The code below is what I managed to get some functionality from but far from perfect.
- Even though I’ve created the mask file (PNG, 324x209 white with a 2 px black border), on the top of the list, when scrolling you see the next row being rendered above the mask area.
- The text in the row is cut off
- When I use the bgColor in the list options and set it to red ( {255,0,0,255} ) it turns out yellow!
- the text look stretched or something, it isn’t crisp
- With the above mentioned mask file, strange things happen, like a sort of gradient fill to the rows.
The weird thing is when I create a pure white mask file with the exact dimensions of my list (320x205 in this case), the display looks better. No more gradient color of the row and it responds to color changes as it should.
[update 2]
Even weirder. It doesn’t load the mask file at all. The command maskFile = “mask.png” simply is ignored. Not matter what I put in, mask=“gg”, maskfile=“mask.png”, maskFile = “invalidname.png”, Corona doesn’t generate an error and the code runs, but apparently without mask. That would explain why I see the rendering of the rows.
Bug?
In the sample code in the onRowRender to say only:
row.textObj = text
But that only drops all the text on the top of the screen and not in the rows.
So I added:
group:insert(row.textObj)
Anyway. I would appreciate some help before I try to apply the new tableView to my app that runs smoothly on build 704.
Thanks!!
Dutchottie
[code]
local widget = require “widget”
– create the tableView widget
local list = widget.newTableView{
–width = 320,
height = 205,
top = display.contentHeight - 205,
maskFile = “mask320x205.png”,
bgColor = { 255, 0, 0, 255 },
hideBackground = false
}
– function below handles row touches, swipes, etc.
local function onRowTouch( event )
local row = event.row
local text = row.textObj
if event.phase == “press” or event.phase == “tap” then
if text then
text.text = "Touched row with id " … row.id
end
elseif event.phase == “swipeLeft” then
if text then
text.text = “Swiped row " … event.index … " LEFT.”
end
elseif event.phase == “swipeRight” then
if text then
text.text = “Swiped row " … event.index … " RIGHT.”
end
elseif event.phase == “release” then
text.text = “”
– force row re-render on next TableView update
row.reRender = true
end
– reposition text
if text then
text:setReferencePoint( display.CenterLeftReferencePoint )
text.x = 25
text.y = row.height * 0.5
end
end
– function below handles row rendering
local function onRowRender( event )
local group = event.view
local row = event.target
local index = event.index
local id = event.id
–local theString = “this is the text to display in the row”
local theString = “Row #” … index … " id: " … id
local text = display.newText( theString, 0, 0, native.systemFont, 14 )
text:setReferencePoint( display.CenterLeftReferencePoint )
text:setTextColor(0)
text.x = 15
text.y = row.height * 0.5
– create reference to text object (so it can be accessed externally)
row.textObj = text
group:insert(text)
end
for i=1,20 do
local rowHeight, rowColor, lineColor, isCategory
rowColor = {255,255,255}
rowHeight = 50
–lineColor = {0,0,0,255}
–if i == 5 then rowHeight = 30 end
if i == 10 then rowColor = {255,0,0,255} end
– function below is responsible for creating the row
list:insertRow{
id = i,
listener=onRowTouch,
onRender=onRowRender,
height=rowHeight,
isCategory=isCategory,
rowColor=rowColor,
lineColor=lineColor
}
end
[import]uid: 123200 topic_id: 22777 reply_id: 322777[/import]
