I took as a basis an example from the Android Universal-Image-Loader removed all unnecessary, slightly redid, and now I just want to reuse the gallery in the project. Gallery takes pictures from the file Constants.java.

public class Constants{ private static String[] image1= new String[] { // Heavy images "https://img1.goodfon.ru/original/1440x900/2/96/art-sono-devushki-shkolnicy.jpg", "https://img1.goodfon.ru/original/1440x900/2/96/art-sono-devushki-shkolnicy.jpg", "https://img1.goodfon.ru/original/1440x900/2/96/art-sono-devushki-shkolnicy.jpg" }; private static String[] image2= new String[] { // Heavy images "https://img1.goodfon.ru/original/1440x900/2/96/art-sono-devushki-shkolnicy.jpg", "https://img1.goodfon.ru/original/1440x900/2/96/art-sono-devushki-shkolnicy.jpg", "https://img1.goodfon.ru/original/1440x900/2/96/art-sono-devushki-shkolnicy.jpg" }; public static String[] IMAGES = Metal; private Constants() {} public static class Config { public static final boolean DEVELOPER_MODE = false; } public static class Extra { public static final String FRAGMENT_INDEX = "com.nostra13.example.universalimageloader.FRAGMENT_INDEX"; public static final String IMAGE_POSITION = "com.nostra13.example.universalimageloader.IMAGE_POSITION"; } } 

Initially public static String[] IMAGES was assigned an array of links. And then it was all called in another activity that was processed and output. Now did as in the code above. And I want, depending on which gallery is running, to assign IMAGES appropriate array of links. For example, something like this:

 public static String[] IMAGES; public static String iden = "iMetal"; switch (iden) { case "iMetal": IMAGES = Metal; break; ... } 

But he writes an unexpected token switch error.

The variable iden planned to transfer from another activity when the gallery was launched.

  • one
    And why did you write the switch outside the body of the method? it cannot and it is a compilation error. Wrap then in a static block: static {switch (iden) {}} if you really want to - Artem Konovalov
  • one
    I apologize for the stupid question, but where in this code is the body of the method? - Skivs
  • one
    that's it, he's not here. You need to declare a method so that it appears. - Artem Konovalov
  • one
    Nowhere, there is no method declared. Try getting started with learning the basics of java . - Nofate
  • All thanks to all! Inserted static everything worked! - Skivs

0