Note that there are some explanatory texts on larger screens.

plurals
  1. POLoad Image using onClickListener
    text
    copied!<p>I have a class that I borrowed from <a href="http://www.androidpeople.com/android-load-image-url-example" rel="nofollow">here</a> 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.</p> <p>OnclickListerner in MainActivity Java:</p> <pre><code>list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3){ showImage go = new showImage(); } }); </code></pre> <p>and this is my showImage class:</p> <pre><code>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; } } } </code></pre> <p>Do I need to call a new layout and then attach my showImage object to it? Any help would be great. Thanks in Advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload