How to make my own scrollview?

Hello everyone…

I would like to be able to do a scroll view, or a table with information

kind of the “phone list” on iPhone

or phone contancts

where you have “rows” and “columns”

and being able to add more and more “rows” every time…

I have a very simple code

row1 = display.newRect( 0, 0, 600, 20 )     sceneGroup:insert(row1)     row1.x = display.contentCenterX     row1.y = display.contentCenterY     row1:setFillColor( .68, .93, .93 )     function row1:touch( event )     if event.phase == "began" then           print("touching row1")         -- set touch focus         display.getCurrentStage():setFocus( self )         self.isFocus = true     elseif self.isFocus then     if event.phase == "moved" then         print( "Moving row1" )         self.x = row1.x     elseif event.phase == "ended" or event.phase == "cancelled" then         print("not touching anything")         -- reset touch focus         display.getCurrentStage():setFocus( nil )         self.isFocus = nil     end     end     return true     end     row1:addEventListener( "touch", row1 )

So if I touch the row1, then when I “moved” the mouse, the “row1”

supposed to move where the mouse is…

Could you help me with this please…

Is there a reason you do not want to use widget.newTableView() for this?

Rob

Hi Rob… I did not know about the table view… I was looking yesterday at night on Corona, and I found it.

I will try to make it work today.

I saw one video from Jay White but only the First Part, when he was going to say how to put data, I could not find the second part.

Then I saw the Corona University, but the data was really confusing, I did not get that.

And another article on line, also confusing

Any suggestions in how to make it simple?


After trying the code, I can see the table, the lines and scroll…Good!

I can change the color of the “categories” I guess… The Wider Row on top.

I see Row1, row2, row3, and so forth…

3 questions.

1.- How do I change row1, row2, with my own information, like Piano, Guitar, Bass, like that

2.- How do I add, another column, or more, like

Piano              Song3            easy

Guitar              Song7           hard

3.- And How do I add an event listener or something

so when people “tap” or “touch” … Piano, this will take them to piano page

or if they “tap” … easy a function will do something

Thanks Rob

Victor

On question 4, you need tableView:removeSelf(). “:” not “.”

Thanks I add it to a sceneGroup and it worked!

I found this

Tutorial: Advanced TableView Tactics

and some part I saw

“However, while this works great for simple cases, it won’t work for more advanced table views that contain “category” rows or empty rows for spacing purposes”

But I got myData = { }

and still I can not get the information to show on the table (For question 1)

I guess that also will solve question 2, because it has “name” and “phone”

that will be the same as “Piano” and “Song3” and “Easy”

on question 3 - I add an extra function

local function onRowTouch()
audio.play(playDo)
end

but when I touch the row – it plays the sound

when I “ended” or let go – it plays the sound

I want it only “once”

Is there a reason you do not want to use widget.newTableView() for this?

Rob

Hi Rob… I did not know about the table view… I was looking yesterday at night on Corona, and I found it.

I will try to make it work today.

I saw one video from Jay White but only the First Part, when he was going to say how to put data, I could not find the second part.

Then I saw the Corona University, but the data was really confusing, I did not get that.

And another article on line, also confusing

Any suggestions in how to make it simple?


After trying the code, I can see the table, the lines and scroll…Good!

I can change the color of the “categories” I guess… The Wider Row on top.

I see Row1, row2, row3, and so forth…

3 questions.

1.- How do I change row1, row2, with my own information, like Piano, Guitar, Bass, like that

2.- How do I add, another column, or more, like

Piano              Song3            easy

Guitar              Song7           hard

3.- And How do I add an event listener or something

so when people “tap” or “touch” … Piano, this will take them to piano page

or if they “tap” … easy a function will do something

Thanks Rob

Victor

On question 4, you need tableView:removeSelf(). “:” not “.”

Thanks I add it to a sceneGroup and it worked!

I found this

Tutorial: Advanced TableView Tactics

and some part I saw

“However, while this works great for simple cases, it won’t work for more advanced table views that contain “category” rows or empty rows for spacing purposes”

But I got myData = { }

and still I can not get the information to show on the table (For question 1)

I guess that also will solve question 2, because it has “name” and “phone”

that will be the same as “Piano” and “Song3” and “Easy”

on question 3 - I add an extra function

local function onRowTouch()
audio.play(playDo)
end

but when I touch the row – it plays the sound

when I “ended” or let go – it plays the sound

I want it only “once”