[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);
Running the above code will give you the following error:
{noformat}
[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}]
{noformat}
You 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.
[https://github.com/appcelerator/hyperloop-examples]
The 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.
Thank you in advanced.
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?
@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!
I'm getting to Android's native ListView using this code (hope it will helps)