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; public static String data = "Metal"; static { switch (data) { case "Metal": IMAGES = Metal; break; case "Marketing": IMAGES = Marketing; break; } 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"; } }
How can I stuff a variable from another activity into the data
variable?
For example, so that when starting the activity in data
obstructed by "Metal"
.
... public void btnClick (View view) { Intent intent = new Intent(this, Metal.class); intent.putExtra(Constants.Extra.FRAGMENT_INDEX, ImageGridFragment.INDEX); startActivity(intent); } ...
I tried through Intent
, but even did not work. Most likely due to the fact that not one method is declared in Constants.java. And how to correctly declare it so that I do not know all the work.