I am trying to access android's R
object in NativeScript with Angular but I haven't had any success. The instructions here say to do it like this:
android.R.color.holo_purple
But when I try to import the android
variable from the application
module or the tns-core-modules/platform
module I get an error that the R
property on the android
object is undefined. How do I get access to R
?
you don't need to import
android
variable fromapplication
module. it is automatically available by default at runtime. to remove compile time errorproperty doesn't exists
just declare the variable namedandroid
toany
.for example.
The
android
here is the main namespace for the Android SDK and not theandroid
property from theapplication
module.See this StackOverflow answer for instruction on how to access the native SDK via TypeScript or use the instruction from the related documentation article
Couldn't get existing answers to work in latest nativescript / angular. I resolved it with the following:
Created a file App_Resources/Android/values/keys.xml
Import these
then to grab the string