0

In my project, I have to display both remote and local images. I can display remote images using Volley NetworkImageView.

 NetworkImageView networkImgVw = (NetworkImageView)rootView.findViewById(R.id.niv);
 networkImgVw.setImageUrl(url, imageLoader);

However, I fail to use NetworkImageView to display local images.

 Bitmap bitmap = BitmapFactory.decodeFile(path, bmOptions);
 coverImgVw.setImageBitmap(bitmap);

Does anybody have a solution to this problem ?

Kelvin Tan
  • 982
  • 1
  • 12
  • 33
  • possible duplicate of [Let Volley's NetworkImageView show local image files](http://stackoverflow.com/questions/22464744/let-volleys-networkimageview-show-local-image-files) – gnuanu Aug 11 '14 at 09:08
  • I think this may solve your problem http://stackoverflow.com/questions/4181774/show-image-view-from-file-path-in-android – Tlife Feb 05 '15 at 04:51

1 Answers1

0

I have figured it out. I put the solution here in case that anyone has the same problem. Inside the NetworkImageView.java, I just change as follows:

 private void loadImageIfNecessary(final boolean isInLayoutPass) {

 ...
 if (TextUtils.isEmpty(mUrl)) {
            if (mImageContainer != null) {
                mImageContainer.cancelRequest();
                mImageContainer = null;
            }
            //setImageBitmap(null); comment out this line 

            return;
        }


}
Kelvin Tan
  • 982
  • 1
  • 12
  • 33
  • Yes, it can display both network image and local image. When you comment out setImageBitmap(null), the networkimageview just functions as normal ImageView – Kelvin Tan Aug 12 '14 at 09:24