Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7415] Android: UI.Picker columns property causes exception with multi-column spinner style

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2012-01-25T22:58:08.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterPaul Dowsett
AssigneeMarshall Culpepper
Created2012-01-25T21:46:41.000+0000
Updated2017-03-09T23:20:06.000+0000

Description

Problem

The [Titanium.UI.Picker.columns](http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Picker.columns-property.html) property causes an exception.

Test case

Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow({
	exitOnClose: true,
	layout: 'vertical'
});

var fruit = [ 'Bananas', 'Strawberries', 'Mangos', 'Grapes' ];
var color = [ 'red', 'green', 'blue', 'orange' ];

var column1 = Ti.UI.createPickerColumn();

for(var i=0, ilen=fruit.length; i<ilen; i++){
  var row = Ti.UI.createPickerRow({
    title: fruit[i]
  });
  column1.addRow(row);
}

var column2 = Ti.UI.createPickerColumn();

for(var i=0, ilen=color.length; i<ilen; i++){
  var row = Ti.UI.createPickerRow({
    title: color[i]
  });
  column2.addRow(row);
}

var picker = Ti.UI.createPicker({
  top:50,
  useSpinner: true,
  columns: [column1, column2], // disable this to resolve issue
  visibleItems: 3,
  selectionIndicator: false
});

// picker.add([column1,column2]); // enable this to resolve issue

win.add(picker);

win.open();

// must be after picker has been displayed
picker.setSelectedRow(0, 2, false);
picker.setSelectedRow(1, 3, false);

Logs

  605          AndroidRuntime  D  >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
  605          AndroidRuntime  D  CheckJNI is ON
  605          AndroidRuntime  D  --- registering native functions ---
   60         ActivityManager  I  Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x
                                  10000000 cmp=com.appcelerator.testing10/.Testing10Activity }
  605          AndroidRuntime  D  Shutting down VM
   60         ActivityManager  I  Start proc com.appcelerator.testing10 for activity com.appcelerator.testing10/.Testing10Activity: pid=61
                                  2 uid=10040 gids={1015, 3003}
  605          AndroidRuntime  I  NOTE: attach of thread 'Binder Thread #3' failed
  612           TiApplication  I  (main) [0,0] checkpoint, app created.
  612           TiApplication  I  (main) [787,787] Titanium 1.8.0.1 (2011/12/22 13:09 fbdc96f)
  612               TiFastDev  D  (main) [189,976] Enabling Fastdev on port 53141
  612               TiFastDev  D  (main) [21,997] sent tokens successfully
  612               TiFastDev  D  (main) [1,998] Fastdev session handshake succesful.
  612           TiApplication  I  (main) [6,1004] Titanium Javascript runtime: v8
  612           TiApplication  W  (main) [166,1170] activity stack is emtpy, unable to get current activity
  612          TiRootActivity  I  (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
  612           TiApplication  W  (main) [281,281] activity stack is emtpy, unable to get current activity
  612           TiApplication  W  (main) [1,282] activity stack is emtpy, unable to get current activity
  612           TiApplication  W  (main) [0,282] activity stack is emtpy, unable to get current activity
  612           TiApplication  E  (KrollRuntimeThread) [1065,1347] APP PROXY: ti.modules.titanium.app.AppModule@44fcbc68
  612           TiAssetHelper  D  Fetching "app.js" with Fastdev...
  612       PickerColumnProxy  W  Unexpected type not added to picker column: ti.modules.titanium.ui.PickerColumnProxy
  612       PickerColumnProxy  W  Unexpected type not added to picker column: ti.modules.titanium.ui.PickerColumnProxy
  612          AndroidRuntime  D  Shutting down VM
  612           TiApplication  E  (main) [946,2293] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to sta
                                  rt activity ComponentInfo{com.appcelerator.testing10/com.appcelerator.testing10.Testing10Activity}: java
                                  .lang.NullPointerException; Titanium 1.8.0.1,2011/12/22 13:09,fbdc96f
  612           TiApplication  E  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.appcelerator.testing10/com.appcel
                                  erator.testing10.Testing10Activity}: java.lang.NullPointerException
  612           TiApplication  E  	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
  612           TiApplication  E  	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  612           TiApplication  E  	at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  612           TiApplication  E  	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  612           TiApplication  E  	at android.os.Handler.dispatchMessage(Handler.java:99)
  612           TiApplication  E  	at android.os.Looper.loop(Looper.java:123)
  612           TiApplication  E  	at android.app.ActivityThread.main(ActivityThread.java:4627)
  612           TiApplication  E  	at java.lang.reflect.Method.invokeNative(Native Method)
  612           TiApplication  E  	at java.lang.reflect.Method.invoke(Method.java:521)
  612           TiApplication  E  	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  612           TiApplication  E  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  612           TiApplication  E  	at dalvik.system.NativeStart.main(Native Method)
  612           TiApplication  E  Caused by: java.lang.NullPointerException
  612           TiApplication  E  	at java.util.Arrays$ArrayList.<init>(Arrays.java:49)
  612           TiApplication  E  	at java.util.Arrays.asList(Arrays.java:171)
  612           TiApplication  E  	at ti.modules.titanium.ui.widget.picker.TextWheelAdapter.<init>(TextWheelAdapter.java:28)
  612           TiApplication  E  	at ti.modules.titanium.ui.widget.picker.TiUISpinnerColumn.refreshNativeView(TiUISpinnerColumn.java:180)
                                  
  612           TiApplication  E  	at ti.modules.titanium.ui.widget.picker.TiUISpinnerColumn.<init>(TiUISpinnerColumn.java:38)
  612           TiApplication  E  	at ti.modules.titanium.ui.PickerColumnProxy.createView(PickerColumnProxy.java:219)
  612           TiApplication  E  	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:440)
  612           TiApplication  E  	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:427)
  612           TiApplication  E  	at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:456)
  612           TiApplication  E  	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:441)
  612           TiApplication  E  	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:427)
  612           TiApplication  E  	at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:520)
  612           TiApplication  E  	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:264)
  612           TiApplication  E  	at android.os.Handler.dispatchMessage(Handler.java:95)
  612           TiApplication  E  	at org.appcelerator.kroll.common.TiMessenger.dispatchMessage(TiMessenger.java:318)
  612           TiApplication  E  	at org.appcelerator.kroll.common.TiMessenger.dispatchPendingMessages(TiMessenger.java:303)
  612           TiApplication  E  	at org.appcelerator.kroll.common.TiMessenger$2.getResult(TiMessenger.java:188)
  612           TiApplication  E  	at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:215)
  612           TiApplication  E  	at org.appcelerator.kroll.common.TiMessenger.sendBlockingRuntimeMessage(TiMessenger.java:143)
  612           TiApplication  E  	at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:417)
  612           TiApplication  E  	at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:337)
  612           TiApplication  E  	at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:117)
  612           TiApplication  E  	at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:46)
  612           TiApplication  E  	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  612           TiApplication  E  	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  612           TiApplication  E  	... 11 more
  612          AndroidRuntime  E  FATAL EXCEPTION: main
  612          AndroidRuntime  E  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.appcelerator.testing10/com.appcel
                                  erator.testing10.Testing10Activity}: java.lang.NullPointerException
  612          AndroidRuntime  E  	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
  612          AndroidRuntime  E  	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  612          AndroidRuntime  E  	at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  612          AndroidRuntime  E  	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  612          AndroidRuntime  E  	at android.os.Handler.dispatchMessage(Handler.java:99)
  612          AndroidRuntime  E  	at android.os.Looper.loop(Looper.java:123)
  612          AndroidRuntime  E  	at android.app.ActivityThread.main(ActivityThread.java:4627)
  612          AndroidRuntime  E  	at java.lang.reflect.Method.invokeNative(Native Method)
  612          AndroidRuntime  E  	at java.lang.reflect.Method.invoke(Method.java:521)
  612          AndroidRuntime  E  	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  612          AndroidRuntime  E  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  612          AndroidRuntime  E  	at dalvik.system.NativeStart.main(Native Method)
  612          AndroidRuntime  E  Caused by: java.lang.NullPointerException
  612          AndroidRuntime  E  	at java.util.Arrays$ArrayList.<init>(Arrays.java:49)
  612          AndroidRuntime  E  	at java.util.Arrays.asList(Arrays.java:171)
  612          AndroidRuntime  E  	at ti.modules.titanium.ui.widget.picker.TextWheelAdapter.<init>(TextWheelAdapter.java:28)
  612          AndroidRuntime  E  	at ti.modules.titanium.ui.widget.picker.TiUISpinnerColumn.refreshNativeView(TiUISpinnerColumn.java:180)
                                  
  612          AndroidRuntime  E  	at ti.modules.titanium.ui.widget.picker.TiUISpinnerColumn.<init>(TiUISpinnerColumn.java:38)
  612          AndroidRuntime  E  	at ti.modules.titanium.ui.PickerColumnProxy.createView(PickerColumnProxy.java:219)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:440)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:427)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:456)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:441)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:427)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:520)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:264)
  612          AndroidRuntime  E  	at android.os.Handler.dispatchMessage(Handler.java:95)
  612          AndroidRuntime  E  	at org.appcelerator.kroll.common.TiMessenger.dispatchMessage(TiMessenger.java:318)
  612          AndroidRuntime  E  	at org.appcelerator.kroll.common.TiMessenger.dispatchPendingMessages(TiMessenger.java:303)
  612          AndroidRuntime  E  	at org.appcelerator.kroll.common.TiMessenger$2.getResult(TiMessenger.java:188)
  612          AndroidRuntime  E  	at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:215)
  612          AndroidRuntime  E  	at org.appcelerator.kroll.common.TiMessenger.sendBlockingRuntimeMessage(TiMessenger.java:143)
  612          AndroidRuntime  E  	at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:417)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:337)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:117)
  612          AndroidRuntime  E  	at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:46)
  612          AndroidRuntime  E  	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  612          AndroidRuntime  E  	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  612          AndroidRuntime  E  	... 11 more
   60         ActivityManager  W    Force finishing activity com.appcelerator.testing10/.Testing10Activity
   60         ActivityManager  W    Force finishing activity com.appcelerator.titanium/org.appcelerator.titanium.TiActivity
   60         ActivityManager  W  Activity pause timeout for HistoryRecord{44f478e0 com.appcelerator.testing10/.Testing10Activity}
  329          TiBaseActivity  E  (main) [150281,528726] Layout cleanup.
   60         ActivityManager  W  Activity destroy timeout for HistoryRecord{44f478e0 com.appcelerator.testing10/.Testing10Activity}
  612                 Process  I  Sending signal. PID: 612 SIG: 9
   60         ActivityManager  I  Process com.appcelerator.testing10 (pid 612) has died.

Workaround

Use the add() method rather than the columns property (see test case for example)

Comments

  1. Paul Dowsett 2012-01-25

    Not sure why - cannot reproduce now. :/
  2. Lee Morris 2017-03-09

    Closing ticket as invalid.

JSON Source