I'm trying to load an image in a dialog via "Lazy Image Loader" to an imageview. I've included two code snippets to show the way I'm calling it.
----EDIT-----
Now Using universal image loader 1.8.6
Log.i(Utils.TAG, "Show Photo");
ImageLoader imgLoader = new ImageLoader(a);
imgLoader.DisplayImage(strUrl, image);
this is how i'm calling it since @TalhaQ way didn't work. Said it did not accept those number of paramaters
---- ORIGINAL--- Log cat show a valid url and image when i go to that url. Any ideas?
Utils.java
public Dialog openFeed(final Activity a, final long id) {
final Dialog dialog = new Dialog(a);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.getWindow().getAttributes().windowAnimations = R.style.dialog_animation;
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.feed_item);
//Set the Title & Descr to the Item Selected
TextView title = (TextView) dialog.findViewById(R.id.txtItemTitle);
title.setText(strTitle);
TextView descr = (TextView) dialog.findViewById(R.id.txtItemDescription);
descr.setText(strDescr);
ImageView image = (ImageView) dialog.findViewById(R.id.imgFeedImage);
Log.i(TAG, "strUrl: " + a.getResources().getString(R.string.photoURL) + strUrl);
ImageLoader imageLoader = new ImageLoader(a);
imageLoader.DisplayImage(a.getResources().getString(R.string.photoURL) + strUrl, image);
Button CommentButton = (Button) dialog.findViewById(R.id.dialogButtonComment);
// if button is clicked, close the custom dialog
CommentButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
final AlertDialog addComment = Utils.openComments(a, id);
addComment.show();
}
});
XML:
<ImageView
android:id="@+id/imgFeedImage"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_alignLeft="@+id/txtItemDescription"
android:layout_alignRight="@+id/txtItemDescription"
android:layout_below="@+id/txtItemDescription"
android:contentDescription="@string/itemicon"
android:src="@drawable/gplus"
android:scaleType="fitCenter"
android:maxHeight="200dp"
android:visibility="invisible" />
I am also using the same Lazy Image Loader.I think you are not passing the context correctly.
int loader = R.drawable.loader;//Old image in the imageview
ImageLoader imgLoader = new ImageLoader(ctx); // ctx is the context
imgLoader.DisplayImage(image_url, loader, image);//image is the imageview,image_url is the url to image
Check out my output.If you still needs any help i am attaching my sample.Download it.Check out the link