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'.
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.
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.
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.