Hi, I put a layout (.xml) in res/layout. And try to access it with android.R.layout.[filename], but it cannot work, and when I tried using [packagename].R.layout.[filename] it also cannot work
Also R.layout.[filename] is not working also R is undefined
How to access a layout file from nativescript ?
Thanks
PS. android.R.color.[acolor] is working
Hi,
Currently there is support only for the AndroidManifest.xml and only it get's merged into the final apk.
But with the 1.5 release coming soon there will be support for any resources, that you might want to use in your AndroidManifest.xml, by declaring them.
android.R.color comes from another dependency that we have included by default.
Thats great news thanks
The best and recommended by us way to use plugins and specifically the .aar library generated by android studio. You can read the way it works from the docs: https://docs.nativescript.org/plugins
In short: if you want to use the full functionality from the plugins: res, AndroidManifest.xml, native source code it's best to build an Android Studio solution and build libraries there which resolve to an .aar file and put this .aar file as the {N} plugin.
further more, if you have any resource inside the res folder it will be bundled inside the final .apk file and will be available to use from the javascript side like so:
example: you have smth.xml inside res/layout/ folder inside an .aar file.
var context = app.android.context;
var res = context.getResources().getIdentifier("smth", "layout", context.getPackageName());
this functionality is trivial when using .aar files.
Invalidate cache and Restart.
Most helpful comment
Invalidate cache and Restart.