Reputation: 4290
I'm writing a Phonegap plugin that allows you to capture a screenshot of what is currently on the screen in an Android application, however I'm running into a few problems..
In order to have the plugin working, it must be in a separate package and .java file within the same application folder.
However, as I need to find the Android view by id I need to reference the layout.xml file and the data that is generated in R.java.
I'm using the following code to find the view:
View content = findViewById(R.id.layoutRoot);
Bitmap bitmap = content.getDrawingCache();
And R is flagging as an error, with the message: R cannot be resolved to a variable.
I know from trial and error that this error is because the view ID cannot be found as it exists outside the package.
Is there anyway I can reference this layout ID?
Upvotes: 2
Views: 1014
Reputation: 23171
Just import the R class by adding import xxx.yyy.zzz.R;
to the top of your file (where xxx.yyy.zzz is the package of the R class).
Upvotes: 2