Wednesday, December 25, 2013

Handle image in Android from Url

Setting up the Android Google Volley ImageLoader for NetworkImageView
-----------------------------------------------------------

<com.android.volley.toolbox.NetworkImageView
android:id="@+id/twitter_avatar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginRight="6dip"
/>

NetworkImageView avatar = (NetworkImageView)view.findViewById(R.id.twitter_avatar);
avatar.setImageUrl("http://someurl.com/image.png",mImageLoader);

Or

mRequestQueue = Volley.newRequestQueue(context);
mImageLoader = new ImageLoader(mRequestQueue, new ImageLoader.ImageCache() {
private final LruCache<String, Bitmap> mCache = new LruCache<String, Bitmap>(10);
public void putBitmap(String url, Bitmap bitmap) {
mCache.put(url, bitmap);
}
public Bitmap getBitmap(String url) {
return mCache.get(url);
}
});
NetworkImageView avatar = (NetworkImageView)view.findViewById(R.id.twitter_avatar);

avatar.setImageUrl("http://someurl.com/image.png",mImageLoader);

1 comment:

  1. This is a really informative knowledge, Thanks for posting this informative Information. Covid-19 Cleaning Services Glenolden

    ReplyDelete