• java.lang.IllegalStateException: ImageView no longer exists. You should not use this PhotoViewAttacher any more.


     java.lang.IllegalStateException: ImageView no longer exists. You should not use this PhotoViewAttacher any more.

    这个错误今天碰到了,下面是解决方法,直接上代码

    PhotoViewAttacher  文件中 更改cleanup方法
     
    发现可行
     1     /* 
     2          * @SuppressWarnings("deprecation")  
     3          * public final void cleanup() {  
     4          *      if (null!= mImageView) { 
     5          *          mImageView.get().getViewTreeObserver().removeGlobalOnLayoutListener(this);  
     6          *      }  
     7          *      mViewTreeObserver = null; 
     8          *  
     9          * // Clear  
    10          *      listeners too mMatrixChangeListener = null;  
    11          *      mPhotoTapListener = null; 
    12          *      mViewTapListener = null; 
    13          *  
    14          * // Finally, clear ImageView  
    15          *      mImageView = null; } 
    16          */  
    17         @SuppressWarnings("deprecation")  
    18         public final void cleanup() {  
    19             if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {  
    20                 if (null != mImageView) {  
    21                     mImageView.get().getViewTreeObserver()  
    22                             .removeOnGlobalLayoutListener(this);  
    23                 }  
    24       
    25                 if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) {  
    26                     mViewTreeObserver.removeOnGlobalLayoutListener(this);  
    27       
    28                     mViewTreeObserver = null;  
    29       
    30                     // Clear listeners too  
    31                     mMatrixChangeListener = null;  
    32                     mPhotoTapListener = null;  
    33                     mViewTapListener = null;  
    34                     // Finally, clear ImageView  
    35                     mImageView = null;  
    36                 }  
    37       
    38             } else {  
    39                 if (null != mImageView) {  
    40                     mImageView.get().getViewTreeObserver()  
    41                             .removeGlobalOnLayoutListener(this);  
    42                 }  
    43       
    44                 if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) {  
    45                     mViewTreeObserver.removeGlobalOnLayoutListener(this);  
    46       
    47                     mViewTreeObserver = null;  
    48       
    49                     // Clear listeners too  
    50                     mMatrixChangeListener = null;  
    51                     mPhotoTapListener = null;  
    52                     mViewTapListener = null;  
    53                     // Finally, clear ImageView  
    54                     mImageView = null;  
    55                 }  
    56             }  
    57         }  
  • 相关阅读:
    java集合(5)-List集合
    String.matches()的用法
    1.在配置XML文件时出现reference file contains errors (http://www.springframework.org/schema/beans/...解决方案
    SVN教程(包括小乌龟) 全图解
    刚刚进公司不会SVN 菜鸟感觉好蛋疼-----------SVN学习记
    第二部分初始阶段 第六章 用例
    第二部分初始阶段 第五章 进化式需求
    SQL中分页与distinct冲突解决方案
    Java项目打war包的方法
    H5不能少的功能-滑动分页
  • 原文地址:https://www.cnblogs.com/wangying222/p/6007989.html
Copyright © 2020-2023  润新知