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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:31:45+00:00 2026-06-06T00:31:45+00:00

Hi i’m trying to add an image to an ImageView from a URL i

  • 0

Hi i’m trying to add an image to an ImageView from a URL i have tried loading it as a bitmap but nothing is showing. so does anyone know what the best method to do this is or what i’m doing wrong?

heres my code

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    //Check Preferences which sets UI
    setContentView(R.layout.singlenews);
      TextView headerText = (TextView) findViewById(R.id.header_text);
       headerText.setText("Latest News");


     PostTask posttask;
       posttask = new PostTask();
       posttask.execute();
}

public void loadNews(){

    newsStr = getIntent().getStringExtra("singleNews");




    try {
        JSONObject obj = new JSONObject(newsStr);
        content = obj.getString("content");
          title = obj.getString("title");
          fullName = obj.getString("fullname");
          created = obj.getString("created");
        NewsImageURL = obj.getString("image_primary");
        tagline = obj.getString("tagline");

        meta = "posted by: " + fullName + " " + created;


        URL aURL = new URL("NewsImageURL");
        URLConnection conn = aURL.openConnection();
        conn.connect();
        InputStream is = conn.getInputStream();
        /* Buffered is always good for a performance plus. */
        BufferedInputStream bis = new BufferedInputStream(is);
        /* Decode url-data to a bitmap. */
         bm = BitmapFactory.decodeStream(bis);
        bis.close();
        is.close();
        /* Apply the Bitmap to the ImageView that will be returned. */






        Log.v("lc", "content=" + content);
        Log.v("lc", "title=" + title);
        Log.v("lc", "fullname=" + fullName);
        Log.v("lc", "created=" + created);
        Log.v("lc", "NewsImage=" + NewsImageURL);
        Log.v("lc", "Meta=" + meta);
        Log.v("lc", "tagline=" + tagline);







} catch 
 (JSONException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

}




public class PostTask extends AsyncTask<Void, String, Boolean> {

    @Override
    protected Boolean doInBackground(Void... params) {
        boolean result = false;
        loadNews();
        publishProgress("progress");
        return result;
    }

    protected void onProgressUpdate(String... progress) {
        StringBuilder str = new StringBuilder();
            for (int i = 1; i < progress.length; i++) {
                str.append(progress[i] + " ");

            }
    }

        @Override
    protected void onPostExecute(Boolean result) {
        super.onPostExecute(result);
        Log.v("BGThread", "begin fillin data");

        fillData();

        }
}

public void fillData(){

    NewsView = LayoutInflater.from(getBaseContext()).inflate(R.layout.newsdetailact,
            null);

  TextView Title = (TextView) NewsView.findViewById(R.id.NewsTitle);
  Title.setText(title);

  TextView Tagline = (TextView) NewsView.findViewById(R.id.subtitle);
  Tagline.setText(tagline);

  TextView MetaData = (TextView) NewsView.findViewById(R.id.meta);
  MetaData.setText(meta);




     ImageView NewsImage = (ImageView)NewsView.findViewById(R.id.imageView2);
     NewsImage.setImageBitmap(bm);

  TextView MainContent = (TextView) NewsView.findViewById(R.id.maintext);
  MainContent.setText(content);





  Log.v("BGThread", "Filled results");

adapter = new MergeAdapter();

adapter.addView(NewsView);


setListAdapter(adapter);


}



}
  • 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-06T00:31:47+00:00Added an answer on June 6, 2026 at 12:31 am

    Please use this code spinet convert url images to bitmap and show it in image view .

    URL url = new URL("http://image10.bizrate-images.com/resize?sq=60&uid=2216744464");
    Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
    imageView.setImageBitmap(bmp);
    

    T think it help you.

    Thanks

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.