Picker.setStrings - Example Error

14 views
Skip to first unread message

frc...@gmail.com

unread,
Mar 3, 2016, 9:23:28 AM3/3/16
to CodenameOne Discussions
In your example of Picker.setStrings: https://www.codenameone.com/javadoc/com/codename1/ui/spinner/Picker.html

I've to add :
pick.setType(Display.PICKER_TYPE_STRINGS);

Without this, there an exception:
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
at com.codename1.ui.spinner.Picker.updateValue(Picker.java:309)
at com.codename1.ui.spinner.Picker.setSelectedString(Picker.java:277)
at com.fmra.smartrh.TmMainUI$4.actionPerformed(TmMainUI.java:171)
at com.codename1.ui.Form.dispatchCommand(Form.java:1482)
at com.codename1.ui.SideMenuBar$CommandWrapper$ShowWaiter.run(SideMenuBar.java:1709)
at com.codename1.ui.Display.processSerialCalls(Display.java:1149)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1093)
at com.codename1.ui.Display.mainEDTLoop(Display.java:994)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

Shai Almog

unread,
Mar 3, 2016, 11:28:25 PM3/3/16
to CodenameOne Discussions, frc...@gmail.com
You are too quick ;-)

That sample references some changes we made to picker to make it slighly simpler. We were hoping the release would go out before people actually try the sample code.

The new code implicitly calls:
picker.setType(Display.PICKER_TYPE_STRINGS);

When you set the string values (which makes more sense). The old code expected you to use the setType() first.

Thanks!
Reply all
Reply to author
Forward
0 new messages