PhotoView icon indicating copy to clipboard operation
PhotoView copied to clipboard

Image is not displayed when It is in the footer of a listview and the list has many items.

Open cmenekse opened this issue 10 years ago • 3 comments

I have the following code running in the onPostExecute part of an AsyncTask that downloads images. without photoViewAttacher I have no issues at all but when I put the line

PhotoViewAttacher attacher = new PhotoViewAttacher(stockImageView);

it sometimes works and I can zoom sometimes it does not even show the image. Any Idea on why this might be happening?

Thank you.

   View footerView =((LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_stock_details, null, false);

        if(listview.getFooterViewsCount()>0)
        {
            listview.removeFooterView(lastAddedFooter);
        }

        lastAddedFooter=footerView;
        ImageView stockImageView= (ImageView)footerView.findViewById(R.id.yahooImage);
        stockImageView.setImageBitmap(result);
        PhotoViewAttacher attacher = new PhotoViewAttacher(stockImageView);
        listview.addFooterView(footerView);

Here are the gradle dependencies and SDK versions:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile files('libs/commons-lang3-3.4.jar')
    compile files('libs/gson-2.3.1.jar')
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.commit451:PhotoView:1.2.5'
}
 compileSdkVersion 23
 buildToolsVersion "23.0.3"

cmenekse avatar Apr 12 '16 21:04 cmenekse

I use the PhotoView in the footer of a list and noticed the following:

If the listview does not have too many items on it such that the footer can be directly seen without a need to scroll the listview, The image appears fine with all the functionality.

If there are more items such that the footer is not shown without scrolling then image does not appear. I suspected it had something to do with recycling views but I tried without recycling it and it still not shown.

It displays fine in either case with androids default Imageview.

cmenekse avatar Apr 13 '16 05:04 cmenekse

Honestly, my suggestion would be to drop ListView and place this within a RecyclerView instead. I have had many issues with ListView headers and footers. It is best to move over to using RecyclerView as it has better support and this issues will more than likely go away

Jawnnypoo avatar May 05 '16 03:05 Jawnnypoo

@Jawnnypoo Hello , it has no effective that image is not displayed sometimes when using recyclerView.

shiyingyan avatar Feb 24 '17 10:02 shiyingyan