Hello
I have been recently trying to figure out how I can add individual text and image. I had this method done with Widget 1.0 but when Widget 2.0 came it end up braking the the entire method that I need help. I’m not good when it comes to using tableViews. How would I convert the code I have here to Widget 2.0.
local list = widget.newTableView{ width = 320, height = 448, bottomPadding = 8, hideBackground = true, maskFile = "mask-320x448.png" } list.y = titleBar.y + titleBar.contentHeight \* 0.5 widgetGroup:insert( list ) local rowText = {"floor", "sky","ground"} local function onRowRender( event ) local row = event.row local rowGroup = event.view local label = "List item " local color = 0 --Create the row's text local thisRowText if rowText[row.index] ~= nil then thisRowText = rowText[row.index] else thisRowText = "" end row.textObj = display.newRetinaText( rowGroup, thisRowText, 0, 0,native.systemFontBold, 20 ) row.textObj:setTextColor( color ) row.textObj:setReferencePoint( display.CenterLeftReferencePoint ) row.textObj.x = 90 row.textObj.y = 40 rowGroup:insert( row.textObj ) --Create the row's arrow row.arrow = display.newImage( "rowArrow.png",false ) row.arrow.x = rowGroup.contentWidth - row.arrow.contentWidth \* 2 row.arrow.y = rowGroup.contentHeight \* 0.5 rowGroup:insert( row.arrow ) row.arrow2 = display.newImageRect( "misc"..row.index..".png",60,60) row.arrow2.x = 40 row.arrow2.y = rowGroup.contentHeight \* 0.5 rowGroup:insert( row.arrow2 ) end local function onRowTouch( event ) local row = event.row local background = event.background if event.phase == "press" then print( "Pressed row: " .. row.index ) background:setFillColor( 0, 110, 233, 255 ) elseif event.phase == "release" or event.phase == "tap" then director:changeScene("misc"..row.index) print( "Tapped and/or Released row: " .. row.index ) background:setFillColor( 0, 110, 233, 255 ) row.reRender = true end end -- insert rows into list (tableView widget) for i = 1, 3 do list:insertRow{ height = 85, rowColor = { 255, 255, 255, 60 }, onRender = onRowRender, listener = onRowTouch } end
The part I’m always stump is at onRowRender function. That is where the error always happens.