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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:52:23+00:00 2026-06-08T01:52:23+00:00

This is what this piece of code is supposed to do. When the button

  • 0

This is what this piece of code is supposed to do.

When the button is pressed, it is supposed to take the current image, and replace it with the one in the url that is in the string “finalurl”

What it does

It takes the current image and just makes it dissappear. It does not replace with any other image. Ive been stuck on this for a few days and im stumped. Any help is appreciated.

Here is the code i used.

public void firstbutton(View view) 
    {
        Context context = view.getContext();
        Drawable image = ImageOperations(context, "@string/finalurl","image.jpg");
        ImageView icon = new ImageView(context);
        icon = (ImageView)findViewById(R.id.imageView);
        icon.setImageDrawable(image);

};


private Drawable ImageOperations(Context ctx, String url, String saveFilename) {
    try {
        InputStream is = (InputStream) this.fetch(url);
        Drawable d = Drawable.createFromStream(is, "src");
        return d;
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}

public Object fetch(String address) throws MalformedURLException,IOException {
    URL url = new URL(address);
    Object content = url.getContent();
    return content;

}

  • 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-08T01:52:24+00:00Added an answer on June 8, 2026 at 1:52 am

    Try This.

    Drawable drawable = LoadImageFromWebOperations(ImageLink);
            imageView.setImageDrawable(drawable);
    
    
      private Drawable LoadImageFromWebOperations(String url)
        {
              try{
    
    
            InputStream is = (InputStream) new URL(url).getContent();
            Drawable d = Drawable.createFromStream(is, "src name");
            return d;
          }catch (Exception e) {
            System.out.println("Exc="+e);
            return null;
          }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this piece of code that is supposed to redirect something written on
I have encountered this piece of code that is supposed to determine the parent
I have this piece of code that is supposed to work on Firefox 3.6
I found this piece of Java code at Wikipedia that is supposed to shuffle
I have this piece of code I found on some blog, that's supposed to
I have this piece of code that is supposed to insert data in a
This piece of code is supposed to go through a list and preform some
Try this piece of code - public class WhitespaceTest { public static void main(String[]
I have this small piece of code String[] words = {{apf,hum_,dkoe,12f}; for(String s:words) {
Mat mask = Mat::zeros(img1.rows, img1.cols, CV_8UC1) this piece of code is supposed to create

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.