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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:11:19+00:00 2026-05-13T08:11:19+00:00

how can we html.fromhtml to load image from web and set into imageview ?

  • 0

how can we html.fromhtml to load image from web and set into imageview ?

  • 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-13T08:11:19+00:00Added an answer on May 13, 2026 at 8:11 am

    Asynchronous Image Downloading

    First thing to do is to make sure you request permission to download images inside the manifest file.

    <uses-permission android:name="android.permission.INTERNET" />
    

    Then, to download an image from the web we need to open an HTTP connection, download and return the image. This method should go inside the activity.

    private Bitmap DownloadImage(String URL)
    

    Then we would then add the downloaded image to the ImageView

    Bitmap bitmap = DownloadImage("http://www.streetcar.org/mim/cable/images/cable-01.jpg");
    ImageView  img = (ImageView) findViewById(R.id.img);
    img.setImageBitmap(bitmap);
    

    However, this isn’t asynchronous.

    Normally we would create a thread to do some background work but a thread can’t update a view it didn’t create.

    To solve this problem we can use AsyncTask. I’ve written this little inner class that extends AsyncTask.

    class DownloadImagesTask extends AsyncTask<String, Integer, Bitmap> {
    
    private int imageViewID;
    
        protected void onPostExecute(Bitmap bitmap1) {
        setImage(imageViewID, bitmap1);
    }
    
        public void setImageId(int imageViewID) {
            this.imageViewID = imageViewID;
        }
    
        @Override
        protected Bitmap doInBackground(String... url) {
            Bitmap bitmap1 = 
                DownloadImage(url[0]);
            return bitmap1;
        }
    

    }

    The three types used by AsyncTask are

    1. Params, the type of the parameters
      sent to the task upon execution.
    2. Progress, the type of the progress units published during the background computation.
    3. Result, the type of the result of the background computation.

    So to replace the old code we can now use

    DownloadImagesTask task1 = new DownloadImagesTask();
    task1.setImageId(R.id.img1);
    task1.execute("http://assets.devx.com/articlefigs/39810_1.jpg");
    

    This got a lot longer than I planned. The codes not perfect but I hope it’s helped you.

    Note: This was is based on Connecting to the web at DevX

    References

    • Connecting to the web :
      http://www.devx.com/wireless/Article/39810/1954
    • AsyncTask:
      http://developer.android.com/reference/android/os/AsyncTask.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 372k
  • Answers 372k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try replacing : OdbcCommand Cmd = new OdbcCommand("GetNodeID", _Connection); Cmd.CommandType… May 14, 2026 at 7:15 pm
  • Editorial Team
    Editorial Team added an answer Try array_diff(); PHP Documentation: http://php.net/manual/en/function.array-diff.php May 14, 2026 at 7:15 pm
  • Editorial Team
    Editorial Team added an answer I tried to look for such a function in Windows… May 14, 2026 at 7:15 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.