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

The Archive Base Latest Questions

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

I have a class that I borrowed from here that loads and image from

  • 0

I have a class that I borrowed from here that loads and image from a URL. I am trying to use the class by calling it from a onClickListener (if that makes sense) But I am not sure how to call the class and show the results. Right now I am just working with a static URL but eventually I it will be dynamic.

OnclickListerner in MainActivity Java:

list.setOnItemClickListener(new OnItemClickListener() {

    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){
        showImage go = new showImage();
    }

});

and this is my showImage class:

package com.flash_tattoo;

public class showImage extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fullimage);

        ImageView imgView =(ImageView)findViewById(R.id.ImageView01);
        String url = null;
        Drawable drawable = LoadImageFromWebOperations("http://www.androidpeople.com/wp-content/uploads/2010/03/android.png");
        imgView.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;
        }
    }
}

Do I need to call a new layout and then attach my showImage object to it? Any help would be great. Thanks in Advance.

  • 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-24T06:06:52+00:00Added an answer on May 24, 2026 at 6:06 am

    First point, Java naming conventions have class names capitalised, this allows anybody reading the code to instantly know what’s what. Please rename the showImage class.

    Secondly, this will cause a long running operation to happen in the UI thread, this is best done with an AsyncTask – see this article on Painless Threading – or a new Thread with a Handler. Long running operations on the UI thread will block any input handler events from being processed in a timely fashion and could cause your application to become unresponsive, especially with a slow mobile connection. Consider adding a progress bar or some method of letting the user know that the application is still doing something while they wait.

    To answer the original question, it looks like showImage is an Activity. This means that inside the listener you don’t need to create a new showImage object, but rather fire off an Intent to view that Activity. Assuming you have the correct layout files I don’t see anything that won’t work here.

    You also seem to have an unused variable, String url = null; is not needed.

    Edit: You also shouldn’t really be using System.out.println(), although it will have the desired results. The standard method of logging in Android is to use the LogCat system.

    As suri has mentioned, it’s also not necessary to have an entire new Activity to show your image. If you move the showImage class functions into your first Activity and add an ImageView to the first layout, you can load the image in the same Activity as the button.

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

Sidebar

Related Questions

I have a class that I want to use to store properties for another
I have class ShowCase that inherite from my class ContentMC (that inherite from MovieClip).
I have class that extends 'IntentService' - this class occasionally receives data from a
I have class myCollection that inherit from Dictionary. Want to hide the add method
Hello all I have class that inherited from Qtreeview and I implement simple (
I have class that represents users. Users are divided into two groups with different
I have class method that returns a list of employees that I can iterate
I have a class that map objects to objects, but unlike dictionary it maps
I have a class that I wish to expose as a remote service using
I have a class that looks like this public class SomeClass { public SomeChildClass[]

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.