EDIT:
Please try to use the Activity.this as the context,if you are using fragments then use getActivity()
Download picasso library from http://square.github.io/picasso/
Then try using this method
Picasso.with(context)
.load(url)
.placeholder(R.drawable.user_placeholder)
.error(R.drawable.user_placeholder_error)
.into(imageView);
And they have some issues with the high resolution images and https protocols if you still cant load with picasso then try
Glide library
String url = myUrls.get(position);
Glide.with(myFragment)
.load(url)
.centerCrop()
.placeholder(R.drawable.loading_spinner)
.crossFade()
.into(myImageView);
You can download Glide from here
https://github.com/bumptech/glide/releases
UPDATE:
For some reason the https appended links are not loaded in both glide and picasso in this case i used the Universal image loading library..
ImageLoader imageLoader;
ImageView iv;
private ImageLoadingListener animateFirstListener = null;
DisplayImageOptions doption_two = null;
Inside the onCreate
imageLoader = ImageLoader.getInstance();
doption_two = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.ic_launcher)
.showImageForEmptyUri(R.drawable.icon)
.showImageOnFail(R.drawable.icon).cacheInMemory(true)
.cacheOnDisc(true).considerExifParams(true).build();
animateFirstListener = new AnimateFirstDisplayListener();
iv = (ImageView) findViewById(R.id.imageView1);
String url = "http://www.bahrainlocator.gov.bh/blm_data/point_1418646022.jpg";
imageLoader.displayImage(url, iv, doption_two, animateFirstListener);
Also declare a static inner class
private static class AnimateFirstDisplayListener extends
SimpleImageLoadingListener {
static final List<String> displayedImages = Collections
.synchronizedList(new LinkedList<String>());
@Override
public void onLoadingComplete(String imageUri, View view,
Bitmap loadedImage) {
if (loadedImage != null) {
ImageView imageView = (ImageView) view;
boolean firstDisplay = !displayedImages.contains(imageUri);
if (firstDisplay) {
FadeInBitmapDisplayer.animate(imageView, 500);
displayedImages.add(imageUri);
}
}
}
}
As helper classes, I have added the
UILApplication.java
public class UILApplication extends Application {
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@SuppressWarnings("unused")
@Override
public void onCreate() {
if (Config.DEVELOPER_MODE
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll().penaltyDialog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll().penaltyDeath().build());
}
super.onCreate();
initImageLoader(getApplicationContext());
}
public static void initImageLoader(Context context) {
// This configuration tuning is custom. You can tune every option, you
// may tune some of them,
// or you can create default configuration by
// ImageLoaderConfiguration.createDefault(this);
// method.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
context).threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
.tasksProcessingOrder(QueueProcessingType.LIFO)
.writeDebugLogs() // Remove for release app
.build();
// Initialize ImageLoader with configuration.
ImageLoader.getInstance().init(config);
}
}
And a constants.java
/**
* @author George Thomas
*/
public final class Constants {
public static class Config {
public static final boolean DEVELOPER_MODE = false;
}
}
Make sure that you make the application name in the manifest as .UILApplication
<application
android:name=".UILApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
You can find the jar file at Univerasl Image loader