I have created a string array, but am unable to access it in my java. I'm pretty new to java, so any help would be greatly appreciated!
This is part of an android app that will use the string array for captions below a bunch of pictures in a series.
Here's what I have. If I comment out these two lines it still runs:
Resources res=getResources();
String[] captionArray=res.getStringArray(R.array.chapter0captions);
This is part of a class that is used for storing the images and captions i wish to open using the Activities that are my menus (not sure if i explained that well...) I can't figure out what is wrong with those two lines, but I really would like to call upon my array instead of having to copy paste under each part of the switch-case code. Thanks in advance for your help!
import android.app.Application;
import android.content.res.Resources;
public class PositionStorage extends Application {
public static int imageToOpen;
public static String captionToOpen;
public static String imageToOpenString;
Resources res=getResources();
String[] captionArray=res.getStringArray(R.array.chapter0captions);
public void storeTheString(int pos){
int imageNumber=pos+1;
switch (imageNumber) {
case 1:
imageToOpen=0x7f020005;
captionToOpen=captionArray[pos];
break;
case 2:
imageToOpen=0x7f020010;
captionToOpen=captionArray[pos];
break;
case 3:
imageToOpen=0x7f02001b;
captionToOpen=captionArray[pos];
break;