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 9022377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:29:41+00:00 2026-06-16T05:29:41+00:00

My problem is the following: I try to load images to a text view

  • 0

My problem is the following: I try to load images to a text view like this:

URLImageParser p = new URLImageParser(textView, this);     
Spanned htmlSpan = Html.fromHtml(textWithImages, p, null);
textView.setText(htmlSpan);

I followed this example https://stackoverflow.com/a/7442725/1835251

If I load images from the web it works perfectly.

I modified to code a bit to load certain images from SDCard as well.

In the “doInBackground” Method of the async task I implemented this:

@Override  
protected Drawable doInBackground(String... params) {  
    String source = params[0];  
    Drawable d = null  
    if(source != null) {  
      if(source.startsWith("/myApp/images/")) {  
          localImage = true;  
      }  
    }  
    if(localImage) {  
      String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();  
      d = Drawable.createFromPath(sdcard+source);  
      d.setBounds(0, 0, 0 + (int)(d.getIntrinsicWidth()), 0   
        + (int) (d.getIntrinsicHeight()));   
      localImage = false;  
    } else {  
      // load images from internet  
    }  
    return d;

localImage is a boolen which is set to determine if the current source “points” to an
image from the internet or a local image.

As stated before: Loading images from the internet works perfectly.
BUT when I load images from the SDCard it sometimes happens that not all images are displayed.
The whole text (including the images) gets cut as if it hasn’t been loaded correctly.
I figured out that this happens much more often on a Samsung Galaxy S3 than on a Samsung S Plus.
On the S3 I sometimes load only 1 or 1.5 images and the rest gets cut.
The S Plus always loads all 4 images but rarely cuts the last 2 or 3 sentences of the text.

I think that it is a sort of a timing problem with the AsyncTask but I never worked with it before.

I know this is a really large post but I hope that someone still can help me.

Best regards

Siggy

  • 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-16T05:29:42+00:00Added an answer on June 16, 2026 at 5:29 am

    Ok I am stupid… I solved it!

    I forgot that I only need the AsyncTask if I load images from the internet. For local images I don’t need that.

    Solution for the interested:

    ImageGetter imgGetter = new ImageGetter() {
      @Override
      public Drawable getDrawable(String source) {                      
        String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
        Drawable d = Drawable.createFromPath(sdcard+source);                    
        d.setBounds(0, 0, 0 + (int)(d.getIntrinsicWidth()), 0 
          + (int) (d.getIntrinsicHeight())); 
        return d;
      }
    };
    Spanned htmlSpan = Html.fromHtml(textAndImage, imgGetter, null);
    textView.setText(htmlSpan);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is the following. I try to convert a string into double. In
I'm having a problem with TRY...CATCH blocks. Can someone explain why the following code
I got a little problem. Sometimes, when I try to call the following code,
I am using following code to load public shared images from google drive to
I have the following HTML page: sample_page.html: <h1>sample html page</h1> <script type=text/javascript src=sample_page.js/> The
Why I try to load a fancybox, the content isn't loaded. The problem only
I'm following this tutorial http://www.gamedev.net/page/resources/_/technical/game-programming/how-to-load-a-bitmap-r1966 and I got the problem of wrong value for
I have a problem following from my previous problem . I also have the
Following problem: I want to render a news stream of short messages based on
The following problem happens on both Safari and Chrome, so probably a WebKit issue.

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.