It would be great if the picker automatically had a Cancel and Done button, with the values from the picker being returned into a table when the user taps the done button. Sure would save a lot of time for the developer in coding pickers! In the meantime, I’ve created a similar look using the code below. You can quickly see how much time having Corona do this for me would save for each picker I have to create (I have a screen which uses 4 different pickers!)
[lua]local toolbarGradient = graphics.newGradient( {168, 181, 198, 255 }, {139, 157, 180, 255}, “down” )
– create the actual picker widget with column data
yearPicker = widget.newPickerWheel{
id=“yearPicker”,
font=“Helvetica-Bold”,
top=258,
columns=years
}
– Create the toolbar ui to go above the picker.
pickerBar = display.newRect(0,yearPicker.y - 44, display.viewableContentWidth, 44)
pickerBar.strokeWidth = 1
pickerBar:setStrokeColor(0,0,0, 255)
pickerBar:setFillColor(toolbarGradient)
– Add Cancel Button
cancelButton = widget.newButton{
id = “bCancel”,
style = “blue1Small”,
label = “Cancel”,
onRelease = onButtonRelease
}
cancelButton.x = 35
cancelButton.y = pickerBar.y
– Add Done Button
doneButton = widget.newButton{
id = “bDone”,
style = “blue2Small”,
label = “Done”,
onRelease = onButtonRelease
}
doneButton.x = display.viewableContentWidth - 35
doneButton.y = pickerBar.y [/lua] [import]uid: 64538 topic_id: 33291 reply_id: 333291[/import]