Share Coding

Tutorials, Problems, Stuffs …

Tag Archives: NetworkImageView

Use Volley NetworkImageView with RecyclerView somet

Volley has a component NetworkImageView. It is easy to display image which is dowloaded from the network. However, working with RecyclerView or RecyclerViewPager, it load nothing on the view.

public class RecyclerNetworkImageView extends NetworkImageView {
    public RecyclerNetworkImageView(Context context) {

    public RecyclerNetworkImageView(Context context, AttributeSet attrs) {
        super(context, attrs);

    public RecyclerNetworkImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

    protected void onDetachedFromWindow() {
        // super.onDetachedFromWindow();

When onDetachedFromWindow() being called, the following condition will stop loading image, so we override it through a subclass and it works!

if (mImageContainer != null) {
    // If the view was bound to an image request, cancel it and clear
    // out the image from the view.
    // also clear out the container so we can reload the image if necessary.
    mImageContainer = null;