Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7822423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:55:15+00:00 2026-06-02T07:55:15+00:00

I am new to SO, and although I’ve been through the FAQ’s, I hope

  • 0

I am new to SO, and although I’ve been through the FAQ’s, I hope I get this question right.

THE BACKGROUND

I have been successful in getting data using the Facebook SDK and displaying them in a custom listview. However, as any beginner, I have invariably slowed things down and the listview lags like crazy. To remedy that, I started implementing Lazy Loading using this example from SO: https://stackoverflow.com/a/3068012/450534

THE STUMBLING BLOCK

I this example @Fedor has hard-coded the URL’s into a String Array. Now I want to replace that String array with those fetched from the Facebook query result (JSON).

Also, is that a good example to follow (strictly for this scenario) or is there a better example out there? I have spent close to 2 days just trying to figure the lazy loading part out. But I am stumped either for lack of efficient searching or the fact that I’ve just begun.

I hope this question makes sense. Thank you for your advice.

Cheers….

A sample of the link to an image returned using JSON to parse a Facebook query.

04-23 01:44:28.505: V/PICTURE LINK URL :(3902): https://s-external.ak.fbcdn.net/safe_image.php?d=AQBZ5-jVGrHA2hpU&w=90&h=90&url=http%3A%2F%2Fblog.mozilla.org%2Ftheden%2Fwp-content%2Fthemes%2FTheDen%2Fimg%2Fbg-header.png

A subset of the way @Fedor has hard-coded the URL’s in his example.

private String[] mStrings={
            "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
            "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon.png",
            "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
            "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
            "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
            "http://a1.twimg.com/profile_images/655119538/andbook.png",
            "http://a3.twimg.com/profile_images/768060227/ap4u_normal.jpg",
            "http://a1.twimg.com/profile_images/74724754/android_logo_normal.png",
            "http://a3.twimg.com/profile_images/681537837/SmallAvatarx150_normal.png"
    };

EDIT

The new edit was going to take a lot of space. Therefore, I am linking it pastebin: http://pastebin.com/HZfCTMy6

The facebook API has a bug where if there is a shared post on the News Feed, it does not give a “picture” tag and another query has to be made to get the picture URL using the “object_id” tag. In the pastebin code, this is put in an if + else if code block starting at line number 155

This is really a lengthy piece of code and I appreciated the time you may take going through it.

Any help with this will be really, really appreciated. Over two days and no solution in sight. 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:55:16+00:00Added an answer on June 2, 2026 at 7:55 am

    If you have a hardcoded definition like that:

    class A {
        private String[] strings = { "str1", "str2", ... };
    
        public A() {
            ...
        }
        ...
    }
    

    you can simply break it with adding a setter (and changing for String array to a dynamic collection):

    class A {
        private ArrayList<String> strings;
    
        public A() {
            this.strings = new ArrayList<String>();
            ...
        }
    
        public void addString(String str) {
            this.strings.add(str);
        }
        ...
    }
    

    If there’s code in the constructor that depends on the array to have values, then move it to a new method and call it after you finished adding the strings.

    As for the format of the data from facebook, since they return json it’s easy to get the exact data you need, just extract the needed urls and add them to the list.


    Edit

    This is from your code:

    ArrayList<String> listOfURLS;
    ....
    if (json_data.has("picture"))   {
        for (int j = 0; j < json_data.length(); j++) {
            listOfURLS = new ArrayList<String>();
            listOfURLS.add(changedString);
        }
    } else if (json_data.has("object_id")) {
        getPictureURL();
        listOfURLS = new ArrayList<String>();
        listOfURLS.add(finalPictureFromObjectID);
    }
    

    This of course will result in having just one url in the listOfUrls, you construct a new ArrayList every time, you should not do that.
    It should look something like:

    ArrayList<String> listOfURLS;
    ....
    if (json_data.has("picture"))   {
        for (int j = 0; j < json_data.length(); j++) {
            listOfURLS.add(changedString);
        }
    } else if (json_data.has("object_id")) {
        getPictureURL();
        listOfURLS.add(finalPictureFromObjectID);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm already new in C++CLI , although I have been working on VB and
I'm kind of new to WPF although I have some experience in Forms, and
I'm new to Python and web development (although I have development experience with Client/Server
I am new to both Qt and Linux C++ development (although I have many
I am new to stackoverflow as a member, although I follow this a lot
[Sorry, I'm new in Python. Although it seems to be a very basic question,
I'm fairly new in the Ruby + Rails scene. Although I have a very
Although there's an answer to this question here the circumstances are different however. For
I am quite new to WP7 although have done lot of 2D games before(for
I am new to android and although I got this working before on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.