I am working on a NativeScript project and I am trying to incorporate the RecyclerView
from Android Support Library.
I have added the dependency in the
app/App_Resources/Android/app.gradle
file:
// Uncomment to add recyclerview-v7 dependency
dependencies {
compile 'com.android.support:recyclerview-v7:+'
}
After reading discussions on GitHub issue#2295 and other related issues, I found out that I can include tns-platform-declarations
to get definition files for native android/ios libraries.
I installed them and followed the tns platform declarations documentation
My goal is to compile the following code snippet:
import { ContentView } from "ui/content-view";
declare var android: any;
export class OptimizedListView extends ContentView {
private _android: android.support.v7.widget.RecyclerView;
public _createUI() {
this._android = new android.support.v7.widget.RecyclerView(this._context);
}
};
Even though declaring the var android
as shown above fixes one reference to RecyclerView
, I still receive an error for the initial reference to RecyclerView:
message: 'Namespace 'android.support.v7.widget' has no exported member 'RecyclerView'.'
I also attempted to declare the RecyclerView class separately but without success:
export declare class RecyclerView extends ContentView {}
I understand that the definitions in tns-platform-declarations
only go up to android.support.v7.widget
.
Setting "noEmitOnError" to false as a workaround doesn't seem optimal.
So, how can I expand this declaration to include
android.support.v7.widget.RecyclerView
without running into compilation issues?
Versions:
- "nativescript-dev-typescript": "^0.3.2"
- "tns-platform-declarations": "^2.4.0-2016-09-28-1"
- "typescript": "^2.1.1"
- "tns-core-modules": "next"