[TIMOB-24414] Android - Fails to cast Ti ListView to native ListView
| GitHub Issue | n/a | 
|---|---|
| Type | Bug | 
| Priority | n/a | 
| Status | Open | 
| Resolution | Unresolved | 
| Affected Version/s | n/a | 
| Fix Version/s | n/a | 
| Components | Hyperloop | 
| Labels | android, engSchedule, hyperloop, listview, searchview | 
| Reporter | James O'Leary | 
| Assignee | Jan Vennemann | 
| Created | 2017-02-16T18:56:40.000+0000 | 
| Updated | 2019-09-24T15:47:15.000+0000 | 
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. 
I'm using the following link as a reference: [http://docs.appcelerator.com/platform/latest/#!/guide/Android_Hyperloop_Programming_Guide]
You can use the snippet of code:
var tiListView = Ti.UI.createListView({});
var ListViewClass = require('android.widget.ListView');
var nativeListView = new ListViewClass(tiListView);
Attachments
| File | Date | Size | 
|---|---|---|
| button.js | 2017-02-16T18:51:33.000+0000 | 5508 | 
Hello, Whats your SDK version and Hyperloop version that you are testing on?
@sdarda SDK 6.0.1.GA Hyperloop 2.0.0
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.
Hi, I've found same issue I think rootcause is that in Android ListView is wrapped by 'ListViewWrapper' [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)
I'm seeing this same bug on the latest TiSDK+Hyperloop. Any updates on patching it?
[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}]@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!
if (OS_ANDROID) { const ListView = require('android.widget.ListView'); const View = require('android.view.View'); const ViewGroup = require('android.view.ViewGroup'); (function (tiList) { const listWrapper = new View(tiList); const nativeListView = ViewGroup.cast(listWrapper).getChildAt(1); const list = ListView.cast(nativeListView); // Got ListView here list.smoothScrollToPositionFromTop((itemIndex + 1 /* 1st section*/), 0, 100); })($.eventsFeed); }