[TIMOB-18951] Android: Setting Picker.touchEnabled (to false) crashes
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2015-06-11T03:07:51.000+0000 |
| Affected Version/s | Release 3.5.1, Release 4.0.0 |
| Fix Version/s | Release 4.1.0 |
| Components | Android |
| Labels | picker, touchEnabled |
| Reporter | Fokke Zandbergen |
| Assignee | Ashraf Abu |
| Created | 2015-05-26T09:51:08.000+0000 |
| Updated | 2015-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
PR: https://github.com/appcelerator/titanium_mobile/pull/6900 To test, scons and follow instructions above in alloy.
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 MangosMarking this as resolved as PR has been reviewed and merged.
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