Reputation: 3327
I am new to Java and Android development. I want to show a splashscreen in my PhoneGap 2.2.0 Android App, but when I add
super.setIntegerProperty("splashscreen", R.drawable.splash);
to my main class (extending DroidGap) Eclipse is throwing the error 'splash cannot be resolved or is not a field'.
Upvotes: 1
Views: 3925
Reputation: 3331
The problem is the package of class 'R' in the code below.
super.setIntegerProperty("splashscreen", R.drawable.splash);
When you ctrl+space on the R, it shows import android.R but you have to import the same package in which you MainActivity.java(assume) is placed.Also defaultly there is no splash variable,you can create a new one and also you can use the pre-defined variable named 'ic_launcher'.Then you line of code will be ->
super.setIntegerProperty("splashscreen", R.drawable.ic_launcher);
Hope the problem will be solved..Cheers
Upvotes: 0
Reputation: 28064
I'm using Phonegap version 3 and still had the same problem.
Following on from greg84 I feel its very important to note that it is literally looking for a file called splash.png
or whatever is defined at:
R.drawable.splash
So if this was
R.drawable.jamie
you'd need to include at *\app\platforms\android\res\drawable\jamie.png
Hopefully this clears up the same 1 and a half hour confusion I just had.
Upvotes: 0
Reputation: 16174
R.drawable.splash refers to a file named splash.png in res/drawable (or the resolution specific drawable folders)
Create that file and it will compile correctly.
Upvotes: 1
Reputation: 7599
R
is a class created by the Android SDK when your application is compiled using the resources in the res
folder. Ensure the splash image file exists in /res/drawable/splash.png
(or required equivalent folders).
NB: The image name must be all in lower case.
Upvotes: 8