{ "id": "166104", "key": "TIMOB-24414", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2017-02-16T18:56:40.000+0000", "priority": null, "labels": [ "android", "engSchedule", "hyperloop", "listview", "searchview" ], "versions": [], "issuelinks": [], "assignee": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2019-09-24T15:47:15.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "13715", "name": "Hyperloop", "description": "Hyperloop project" } ], "description": "I'm trying to access native ListView methods. I need to cast a Ti ListView to a native Android ListView to access the native methods. \r\n\r\nI'm using the following link as a reference: [http://docs.appcelerator.com/platform/latest/#!/guide/Android_Hyperloop_Programming_Guide]\r\n\r\nYou can use the snippet of code:\r\n{code:javascript}\r\nvar tiListView = Ti.UI.createListView({});\r\nvar ListViewClass = require('android.widget.ListView');\r\nvar nativeListView = new ListViewClass(tiListView);\r\n{code}\r\n\r\nRunning the above code will give you the following error:\r\n\r\n{noformat}\r\n[ERROR] : HyperloopProxy: (main) [5496,10667] Unable to find matching constructor for class: android.widget.ListView, args: [ti.modules.titanium.ui.widget.listview.TiListView$ListViewWrapper{d8c5545 V.E...CL. ......I. 0,0-0,0 #1e}]\r\n{noformat}\r\n\r\nYou can also can get the Hyperloop-Examples project from appcelerator's github page and replace the button.js controller in the project with the button.js file I attached.\r\n[https://github.com/appcelerator/hyperloop-examples]\r\n\r\nThe reason why I want to access native methods on the ListView is to get the count of visible ListViewRows in the ListView when searching through the ListView with a SearchView. It seems that I can only get the count of all(visible and hidden) ListViewRows in the ListView. If you have a solution for this without using Hyperloop, I'd love to hear that as well.\r\n\r\nThank you in advanced.", "attachment": [ { "id": "61621", "filename": "button.js", "author": { "name": "James.OLeary", "key": "james.oleary", "displayName": "James O'Leary", "active": true, "timeZone": "America/New_York" }, "created": "2017-02-16T18:51:33.000+0000", "size": 5508, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "Android - Fails to cast Ti ListView to native ListView", "creator": { "name": "James.OLeary", "key": "james.oleary", "displayName": "James O'Leary", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "James.OLeary", "key": "james.oleary", "displayName": "James O'Leary", "active": true, "timeZone": "America/New_York" }, "environment": "Hyperloop\r\nAndroid", "comment": { "comments": [ { "id": "407222", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Whats your SDK version and Hyperloop version that you are testing on? ", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-02-16T19:31:29.000+0000", "updated": "2017-02-16T19:31:29.000+0000" }, { "id": "407224", "author": { "name": "James.OLeary", "key": "james.oleary", "displayName": "James O'Leary", "active": true, "timeZone": "America/New_York" }, "body": "@sdarda\r\n\r\nSDK 6.0.1.GA\r\nHyperloop 2.0.0", "updateAuthor": { "name": "James.OLeary", "key": "james.oleary", "displayName": "James O'Leary", "active": true, "timeZone": "America/New_York" }, "created": "2017-02-16T19:36:16.000+0000", "updated": "2017-02-16T19:39:02.000+0000" }, { "id": "407298", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "I have teste dthe issue with SDK 6.0.1.GA with the sample code provided and the hyperloop example project. This is a valid bug. ", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-02-17T16:14:39.000+0000", "updated": "2017-02-17T16:14:39.000+0000" }, { "id": "419266", "author": { "name": "zo0m", "key": "zo0m", "displayName": "Igor Kalashnikov", "active": true, "timeZone": "Europe/Helsinki" }, "body": "Hi, I've found same issue\r\nI think rootcause is that in Android ListView is wrapped by 'ListViewWrapper'\r\n[TiListView.java#L331|https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/TiListView.java#L331]\r\n\r\n{code:title=TiListView.java}\r\n//initializing listView and adapter\r\nListViewWrapper wrapper = new ListViewWrapper(activity);\r\nwrapper.setFocusable(false);\r\nwrapper.setFocusableInTouchMode(false);\r\nlistView = new ListViewScrollEvent(activity);\r\nlistView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));\r\nwrapper.addView(listView); // <==================== HERE\r\nadapter = new TiBaseAdapter(activity);\r\n{code}", "updateAuthor": { "name": "zo0m", "key": "zo0m", "displayName": "Igor Kalashnikov", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2017-05-08T08:19:14.000+0000", "updated": "2017-05-08T08:19:14.000+0000" }, { "id": "434601", "author": { "name": "zettageek", "key": "zettageek", "displayName": "Josh Lambert", "active": true, "timeZone": "America/Chicago" }, "body": "I'm seeing this same bug on the latest TiSDK+Hyperloop. Any updates on patching it?\r\n\r\n{code:java}\r\n[ERROR] HyperloopProxy: (main) [172,492] Unable to find matching constructor for class: android.widget.ListView, args: [ti.modules.titanium.ui.widget.listview.TiListView$ListViewWrapper{882ebb0 V.ED..CL. ......ID 0,0-0,0 #1}]\r\n{code}\r\n", "updateAuthor": { "name": "zettageek", "key": "zettageek", "displayName": "Josh Lambert", "active": true, "timeZone": "America/Chicago" }, "created": "2018-02-17T18:01:12.000+0000", "updated": "2018-02-17T18:01:12.000+0000" }, { "id": "434648", "author": { "name": "James.OLeary", "key": "james.oleary", "displayName": "James O'Leary", "active": true, "timeZone": "America/New_York" }, "body": "@Josh, I think @Ihor is on track with finding a solution. I haven't tried this code or Hyperloop in a while but I think you must use the ListViewWrapper in order to cast the Ti ListView to a native Android ListView. Anyway I'm commenting to say that I've moved on. I've decided Hyperlooop is more of a headache than it's worth. My team is in the transition to write more Native apps while still keeping Appcelerator in our back pocket for select apps. Good luck!", "updateAuthor": { "name": "James.OLeary", "key": "james.oleary", "displayName": "James O'Leary", "active": true, "timeZone": "America/New_York" }, "created": "2018-02-20T13:22:59.000+0000", "updated": "2018-02-20T13:22:59.000+0000" }, { "id": "443474", "author": { "name": "zo0m", "key": "zo0m", "displayName": "Igor Kalashnikov", "active": true, "timeZone": "Europe/Helsinki" }, "body": "{code:title=getAndroidListViewHyperloop.js|borderStyle=solid}\r\n if (OS_ANDROID) {\r\n const ListView = require('android.widget.ListView');\r\n const View = require('android.view.View');\r\n const ViewGroup = require('android.view.ViewGroup');\r\n\r\n (function (tiList) {\r\n const listWrapper = new View(tiList);\r\n const nativeListView = ViewGroup.cast(listWrapper).getChildAt(1);\r\n const list = ListView.cast(nativeListView); // Got ListView here \r\n list.smoothScrollToPositionFromTop((itemIndex + 1 /* 1st section*/), 0, 100);\r\n })($.eventsFeed);\r\n } \r\n{code}\r\n\r\nI'm getting to Android's native ListView using this code (hope it will helps)", "updateAuthor": { "name": "zo0m", "key": "zo0m", "displayName": "Igor Kalashnikov", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2018-11-11T09:14:13.000+0000", "updated": "2018-11-11T09:14:13.000+0000" }, { "id": "443476", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-11T10:08:05.000+0000", "updated": "2018-11-11T10:08:05.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }