Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18951] Android: Setting Picker.touchEnabled (to false) crashes

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-06-11T03:07:51.000+0000
Affected Version/sRelease 3.5.1, Release 4.0.0
Fix Version/sRelease 4.1.0
ComponentsAndroid
Labelspicker, touchEnabled
ReporterFokke Zandbergen
AssigneeAshraf Abu
Created2015-05-26T09:51:08.000+0000
Updated2015-06-17T18:46:16.000+0000

Description

Setting touchEnabled to false causes the app to crash on Android:

Reproducing code

<Alloy>
	<Window>
		<Picker touchEnabled="false"/>
	</Window>
</Alloy>

Log

[ERROR] : TiApplication: (main) [558,558] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.reynald.test4project/org.appcelerator.titanium.TiActivity}: java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead; Titanium 4.0.0,2015/05/18 15:42,9239ff9
[ERROR] : TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.reynald.test4project/org.appcelerator.titanium.TiActivity}: java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead
[ERROR] : TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
[ERROR] : TiApplication: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
[ERROR] : TiApplication: at android.app.ActivityThread.access$600(ActivityThread.java:130)
[ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:137)
[ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:4745)
[ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:511)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method)
[ERROR] : TiApplication: Caused by: java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead
Reported via Q&A: https://community.appcelerator.com/topic/520/app-crashed-when-using-widget-with-picker-in-it/3

Comments

  1. Ashraf Abu 2015-06-09

    PR: https://github.com/appcelerator/titanium_mobile/pull/6900 To test, scons and follow instructions above in alloy.
  2. Hieu Pham 2015-06-09

    Titanium test case:
       Ti.UI.backgroundColor = 'white';
       var win = Ti.UI.createWindow({
         exitOnClose: true,
         layout: 'vertical'
       });
       
       var picker = Ti.UI.createPicker({
         top:50,
         touchEnabled: false
       });
       
       var data = [];
       data[0]=Ti.UI.createPickerRow({title:'Bananas'});
       data[1]=Ti.UI.createPickerRow({title:'Strawberries'});
       data[2]=Ti.UI.createPickerRow({title:'Mangos'});
       data[3]=Ti.UI.createPickerRow({title:'Grapes'});
       
       picker.add(data);
       picker.selectionIndicator = true;
       
       win.add(picker);
       win.open();
       
       // must be after picker has been displayed
       picker.setSelectedRow(0, 2, false); // select Mangos
       
  3. Ashraf Abu 2015-06-11

    Marking this as resolved as PR has been reviewed and merged.
  4. Lokesh Choudhary 2015-06-16

    Verified the fix. Setting touchEnabled to false does not crash the app. Closing Environment: Appc Studio : 4.1.0.201506151224 Ti SDK : 4.1.0.v20150614181235 Ti CLI : 4.0.1 Alloy : 1.6.2 MAC Yosemite : 10.10.3 Appc npm : 4.0.1 Appc CLI : 4.0.2 Node: v0.10.37 Android 5.0.2

JSON Source