0

I have been referring this app to make a gallery module
https://github.com/nostra13/Android-Universal-Image-Loader

However according to the requirement in my app the images are dynamically added.So, I am fetching all the images via JSON.The image response from JSON Iam adding in the arraylist.

How should I pass "image_urls.add(folio.getString(i));" in the new class :

public class Test extends Activity{

    private static String url = "http://www.xyz.com/album_pro/array_to_encode";

     JSONArray folio = null;
     ArrayList<String> urlList = new ArrayList<String>();
     @SuppressLint("NewApi")
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
              StrictMode.setThreadPolicy(policy);

            JSONParser jParser = new JSONParser();
            {

            try{

                JSONObject json = jParser.getJSONFromUrl(url);
                Log.v("URL",json.toString());

            JSONObject seo = json.getJSONObject("SEO");
            Log.v("seo",seo.toString());
            JSONArray folio = seo.getJSONArray("Folio");
            ArrayList<String> image_urls = new ArrayList<String>();

            for(int i=0;i< folio.length();i++)
            {

                image_urls.add(folio.getString(i));

            }


            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            }
}

}

How should I pass "image_urls.add(folio.getString(i));" in a non activity class named "Images" i.e

public class Images {
    public final static String[] imageUrls = new String[] {
      **Required the arraylist of "Test" activity**

    };
    public final static String[] imageThumbUrls = new String[] {

         **Required the arraylist of "Test" activity**
    };

}
5
  • 1
    What is the question? Commented Mar 4, 2013 at 11:27
  • @NikitaBeloglazov : How should I pass "image_urls.add(folio.getString(i));" in the new class i.e Commented Mar 4, 2013 at 11:30
  • @Shweta : where is new class ? in use class constructor if new class is an non activity class Commented Mar 4, 2013 at 11:31
  • @ρяσѕρєяK : its a non activity class Commented Mar 4, 2013 at 11:34
  • @Shweta use ArrayList instead of Array...And get create a method to add elements to the ArrayList Commented Mar 4, 2013 at 11:34

3 Answers 3

1

Make the ArrayList public and static and use it in other class as Test.urlList

Sign up to request clarification or add additional context in comments.

Comments

1

Make the Images members non-final so that you can set them at runtime.

After your loop which add image urls to image_urls ArrayList, set the properties of Images class:

Images.imageUrls = image_urls.toArray();

Comments

0

Simple way is to make the image_urls as public static. since it contains only urls right? only small amount of data and in the Image class access that with

Test.image_urls.get(integer);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.