Picker Wheel does not work in Android

I’m running Corona v2016.2992 and I’m trying to make use of the picker wheel, specifically the resizable type.

In iOS everything works great, but in Android, even the code example from the documentation will not show up, and it’ll crash the app when attempting to use :getValues() or :selectValue. I also tried the non-resizable type and it does not show up in Android either.

Can you provide the code you’re trying to test with?

Please use code formatting when posting (click the blue <> button in the row with Bold, Italics, etc. and paste your code into the window that pops up.)

Thanks

Rob

Thanks for your answer, Rob. As I mentioned, I’m using the code provided as example in the widget.newPickerWheel() documentation. That is:

local widget = require( "widget" ) -- Set up the picker wheel columns local columnData = { { align = "left", width = 124, labelPadding = 20, startIndex = 2, labels = { "Hoodie", "Short Sleeve", "Long Sleeve", "Sweatshirt" } }, { align = "left", width = 96, labelPadding = 10, startIndex = 1, labels = { "Dark Grey", "White", "Black", "Orange" } }, { align = "left", width = 60, labelPadding = 10, startIndex = 3, labels = { "S", "M", "L", "XL", "XXL" } } } -- Create the widget local pickerWheel = widget.newPickerWheel( { x = display.contentCenterX, top = display.contentHeight - 160, columns = columnData, style = "resizable", width = 280, rowHeight = 32, fontSize = 14 }) -- Get the table of current values for all columns -- This can be performed on a button tap, timer execution, or other event local values = pickerWheel:getValues() -- Get the value for each column in the wheel, by column index local currentStyle = values[1].value local currentColor = values[2].value local currentSize = values[3].value print( currentStyle, currentColor, currentSize )

Hi @bernalmurcia,

What else is in your program? Do you set a widget “theme” somewhere before this? Does the program crash if you do not call :getValues() or :selectValue()? What Android device are you testing on, and what version of Android OS?

Best regards,

Brent

I have this empty composer scene in which I try things before I put them somewhere else in my code, that’s where I’m trying it. Also, I’m not setting the widget theme.

If I don’t call :getValues() or :selectValue() it does not crash, it just doesn’t show up (it does show up in the Corona Simulator for an Android device). I’m using a Nexus 5 with the latest version of Android available to it.

I pulled that public widget library that you have available in git to make code customizations to some of the widgets, and that library is also living in my project under the folder layoutWidgets/widgetLibrary. Geting called by 

local customWidget = require( "layoutWidgets.widgetLibrary.widget" )

But both libraries do not interfere and for the picker wheel I’m just using the library pulled via 

local widget = require( "widget" )

If I use the public widget library, which has an old, non-resizable version of the picker wheel, it does work. But not if I use the widget library that came with the latest Corona.

Hi @bernalmurcia,

As far as I can tell by your reports, this is because resizable pickers do not work with “legacy” Android widget themes. That is reflected in the console log, but I don’t blame you for not looking there. I will add a warning on this to the documentation soon.

So basically, because the legacy theme is being chosen by default on Android, you need to explicitly set a more modern “holo” theme, either light or dark, if you want to use resizable pickers (fixed-size pickers can still use the legacy theme).

[lua]

widget.setTheme( “widget_theme_android_holo_dark” )

– OR…

widget.setTheme( “widget_theme_android_holo_light” )

[/lua]

Let me know if you experience other issues after following this advice.

Brent

Ah! Thank you very much, Brent. I’ll give that a try as soon as possible and let you know!

That did the trick. Thanks again!

Is there documentation on changing the / re-skinning the widgets themes?

Hi @doubleslashdesign,

Do you mean re-skinning a particular widget, or changing an entire theme? If the latter, then no (we don’t document it), but for the clever developer, the image sheet files and everything else are available for all built-in themes in the open-source widget library, so you could relatively easily see what frames are used for what parts and put your own in place. Other developers have definitely done this already in the past.

Best regards,

Brent

Can you provide the code you’re trying to test with?

Please use code formatting when posting (click the blue <> button in the row with Bold, Italics, etc. and paste your code into the window that pops up.)

Thanks

Rob

Thanks for your answer, Rob. As I mentioned, I’m using the code provided as example in the widget.newPickerWheel() documentation. That is:

local widget = require( "widget" ) -- Set up the picker wheel columns local columnData = { { align = "left", width = 124, labelPadding = 20, startIndex = 2, labels = { "Hoodie", "Short Sleeve", "Long Sleeve", "Sweatshirt" } }, { align = "left", width = 96, labelPadding = 10, startIndex = 1, labels = { "Dark Grey", "White", "Black", "Orange" } }, { align = "left", width = 60, labelPadding = 10, startIndex = 3, labels = { "S", "M", "L", "XL", "XXL" } } } -- Create the widget local pickerWheel = widget.newPickerWheel( { x = display.contentCenterX, top = display.contentHeight - 160, columns = columnData, style = "resizable", width = 280, rowHeight = 32, fontSize = 14 }) -- Get the table of current values for all columns -- This can be performed on a button tap, timer execution, or other event local values = pickerWheel:getValues() -- Get the value for each column in the wheel, by column index local currentStyle = values[1].value local currentColor = values[2].value local currentSize = values[3].value print( currentStyle, currentColor, currentSize )

Hi @bernalmurcia,

What else is in your program? Do you set a widget “theme” somewhere before this? Does the program crash if you do not call :getValues() or :selectValue()? What Android device are you testing on, and what version of Android OS?

Best regards,

Brent

I have this empty composer scene in which I try things before I put them somewhere else in my code, that’s where I’m trying it. Also, I’m not setting the widget theme.

If I don’t call :getValues() or :selectValue() it does not crash, it just doesn’t show up (it does show up in the Corona Simulator for an Android device). I’m using a Nexus 5 with the latest version of Android available to it.

I pulled that public widget library that you have available in git to make code customizations to some of the widgets, and that library is also living in my project under the folder layoutWidgets/widgetLibrary. Geting called by 

local customWidget = require( "layoutWidgets.widgetLibrary.widget" )

But both libraries do not interfere and for the picker wheel I’m just using the library pulled via 

local widget = require( "widget" )

If I use the public widget library, which has an old, non-resizable version of the picker wheel, it does work. But not if I use the widget library that came with the latest Corona.

Hi @bernalmurcia,

As far as I can tell by your reports, this is because resizable pickers do not work with “legacy” Android widget themes. That is reflected in the console log, but I don’t blame you for not looking there. I will add a warning on this to the documentation soon.

So basically, because the legacy theme is being chosen by default on Android, you need to explicitly set a more modern “holo” theme, either light or dark, if you want to use resizable pickers (fixed-size pickers can still use the legacy theme).

[lua]

widget.setTheme( “widget_theme_android_holo_dark” )

– OR…

widget.setTheme( “widget_theme_android_holo_light” )

[/lua]

Let me know if you experience other issues after following this advice.

Brent

Ah! Thank you very much, Brent. I’ll give that a try as soon as possible and let you know!

That did the trick. Thanks again!

Is there documentation on changing the / re-skinning the widgets themes?

Hi @doubleslashdesign,

Do you mean re-skinning a particular widget, or changing an entire theme? If the latter, then no (we don’t document it), but for the clever developer, the image sheet files and everything else are available for all built-in themes in the open-source widget library, so you could relatively easily see what frames are used for what parts and put your own in place. Other developers have definitely done this already in the past.

Best regards,

Brent