I've got a problem with a simple tutorial code i've follow to learn Recyclerview. First I create a class to represent item like :
package tom_d.fr.testrecyclerview;
import android.content.res.Resources;
import java.util.ArrayList;
public class Planete {
public String mNom;
public int mDistance;
protected ArrayList<Planete> mListe;
Planete(String nom, int distance) {
mNom = nom; // nom de la planète
mDistance = distance; // distance au soleil en Gm
Resources res = getResources();
final String[] noms = res.getStringArray(R.array.noms);
final int[] distances = res.getIntArray(R.array.distances);
mListe = new ArrayList<Planete>();
for (int i=0; i<noms.length; ++i) {
mListe.add(new Planete(noms[i], distances[i]));
}
}
I get error: cannot find symbol method getResources()
Even if I try with :
Resources res = getApplicationContext().getResources();
How to proceed ? I just want to acess to an xml file with arrays :(
I've also search for this error here on stackoverflow and other website but no functionnal answer....
I think I've made a mistake but I don't know where :/