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

  • SEARCH
  • Home
  • 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 7078783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:35:24+00:00 2026-05-28T06:35:24+00:00

Okay, so I have a JSON array of image URLs. I want to load

  • 0

Okay, so I have a JSON array of image URLs. I want to load them into a horizontal scrolling view. This is the way I’ve gone about it, but nothing gets displayed where the ScrollView should go:

public void run() {
    JSONArray photosArray;
    caption = new WebView(thisContext);
    imageScroller = new HorizontalScrollView(thisContext);
    imagesHolder = new LinearLayout(thisContext);
    imagesHolder.setOrientation(LinearLayout.HORIZONTAL);
    try {
        photosArray = new JSONArray(postData.getString("photos"));
        for(int i = 0; i < photosArray.length(); i++) {
            WebView iV = new WebView(thisContext);
            JSONObject thisPhoto = photosArray.getJSONObject(i);
            JSONArray sizesArray = new JSONArray(thisPhoto.getString("alt_sizes"));
            JSONObject largest = sizesArray.getJSONObject(0);
            iV.loadData("<img src=\""+largest.getString("url")+"\" />", "text/html", null);
            imagesHolder.addView(iV);
        }
        imageScroller.addView(imagesHolder);
        myPostHolder.addView(imageScroller);
        caption.loadData(postData.getString("caption"),"text/html",null);
        myPostHolder.addView(caption);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Note that this is done in a runnable class. Thanks a lot

  • 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-05-28T06:35:25+00:00Added an answer on May 28, 2026 at 6:35 am

    There are two rules in the Android single thread model.

    1. Do not block the UI thread
    2. Do not access the Android UI toolkit from outside the UI thread

    So I don’t think you can add views to a viewgroup outside of the main thread. Please see: http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html for a fuller explanation.

    Also, you need to make sure you are actually setting the contentview and you may need to call invalidate() on the viewgroup to cause a redraw.

    And, you probably should be using a GridView..can’t see why you’d use a webview for this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

okay i have found the way to run a video in a image.... the
Okay I have been racking my brain trying to build a JSON array from
Okay so I am making this race schedule and I have it in json
Okay - I have a dilemma. So far my script converts page titles into
okay i have been trying to understand this for hours i am learning VB
Okay so i have this code: if (isset($_GET['book'])) { $query= SELECT book_id, title, authors.`author`
I have a Java servlet, where I want to use the Jackson JSON parser
okay have a this list: object[] test; test[0]=null; .... test[8700]=null; test[8701]= object[] .... test[9431]=
Okay I have a project in CMake structured like this: CMakeLists.txt /libfoo/CMakeLists.txt /frontend/qt/CMakeLists.txt libfoo
Okay I have a JSON file and it has a set of objects that

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.