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

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

在PhotoViewAttacher  文件中 更改cleanup方法
 
发现可行
     /*
* @SuppressWarnings("deprecation")
* public final void cleanup() {
* if (null!= mImageView) {
* mImageView.get().getViewTreeObserver().removeGlobalOnLayoutListener(this);
* }
* mViewTreeObserver = null;
*
* // Clear
* listeners too mMatrixChangeListener = null;
* mPhotoTapListener = null;
* mViewTapListener = null;
*
* // Finally, clear ImageView
* mImageView = null; }
*/
@SuppressWarnings("deprecation")
public final void cleanup() {
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
if (null != mImageView) {
mImageView.get().getViewTreeObserver()
.removeOnGlobalLayoutListener(this);
} if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) {
mViewTreeObserver.removeOnGlobalLayoutListener(this); mViewTreeObserver = null; // Clear listeners too
mMatrixChangeListener = null;
mPhotoTapListener = null;
mViewTapListener = null;
// Finally, clear ImageView
mImageView = null;
} } else {
if (null != mImageView) {
mImageView.get().getViewTreeObserver()
.removeGlobalOnLayoutListener(this);
} if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) {
mViewTreeObserver.removeGlobalOnLayoutListener(this); mViewTreeObserver = null; // Clear listeners too
mMatrixChangeListener = null;
mPhotoTapListener = null;
mViewTapListener = null;
// Finally, clear ImageView
mImageView = null;
}
}
}

java.lang.IllegalStateException: ImageView no longer exists. You should not use this PhotoViewAttacher any more.的更多相关文章

  1. 云笔记项目- 上传文件报错"java.lang.IllegalStateException: File has been moved - cannot be read again"

    在做文件上传时,当写入上传的文件到文件时,会报错“java.lang.IllegalStateException: File has been moved - cannot be read again ...

  2. struts2 下载时报java.lang.IllegalStateException

    -----------------------------------------struts2 下载时报java.lang.IllegalStateException---------------- ...

  3. 异常java.lang.IllegalStateException的解决

    在初始化viewPagerAdapter时,显示异常.从网上找了找有两类这样的问题,一种是说给一个视图设置了两个父类,如: TextView tv = new TextView();layout.ad ...

  4. 开发问题及解决--java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout

    <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android=" ...

  5. java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout

    <TextView android:layout_width="fill_parent" android:layout_height="wrap_content&q ...

  6. tomcat启动时检测到循环继承而栈溢出的问题:Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/test] due to a StackOverflowError. Possible root causes include

    最近在公司更新一个老项目的时候,发现部署项目后tomcat报错,错误如下: Caused by: java.lang.IllegalStateException: Unable to complete ...

  7. myeclipse 无法启动 java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).

    把myeclipse10 按照目录完整拷贝到了另外一台电脑, 另外的目录 原安装目录 D\:\soft\i\myeclipse10 新安装目录 E\:\soft\myeclipse10 双击启动失败, ...

  8. java.lang.IllegalStateException:Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx...}: java.lang.IllegalSta ...

  9. java.lang.IllegalStateException: Not allowed to create transaction on shared EntityManager - use Spring transactions or EJB CMT instead

    java.lang.IllegalStateException: Not allowed to create transaction on sharedEntityManager - use Spri ...

随机推荐

  1. 快速搭建一个restful风格的springboot项目

    1.创建一个工程. 2.引入pom.xml依赖,如下 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi ...

  2. eclipse 启动报错 java was started but returned code=13

    eclipse启动不了,出现“Java was started but returned exit code=13......”对话框如下 我的解决方法是:去控制面板--程序--卸载程序和功能下面查看 ...

  3. 初试百度地图API

    第一次使用百度地图API来定位并显示,参照了官网2.1.0版本demo里的DemoApplication和LocationOverlayDemo两个类来写,整了半天显示一片空白(图一),然后郁闷了半天 ...

  4. cordova百度导航插件使用

    org.ssgroup.sope.cordova.baiduNavi 插件已经开源至 https://github.com/shenshouer/org.ssgroup.sope.cordova.ba ...

  5. memcache学习资料

    memcached是国外社区网站LiveJournal团队开发,通过缓存数据库查询结果,减少数据库访问次数,从而提高动态web站点性能.官方站点 http://memcached.org/memcac ...

  6. win7/win10+vs2015+pcl1.8.0详细配置方案;

    参考网友的资料整理为更详细的解决方案 一.下载相关文件 1.下载PCL-1.8.0-AllInOne-msvc2015-win64.exe.属性表和PDB和测试pcd文件rabbit.pcd,其中,属 ...

  7. 从头认识java-14.4 Java提供的数组的有用功能(2)

    接着上一章节,我们继续介绍Java提供的数组的有用功能. 3.元素的对照Comparator package com.ray.ch14; import java.util.Arrays; import ...

  8. 矩阵十题【五】 VOJ1049 HDU 2371 Decode the Strings

    题目链接:https://vijos.org/p/1049 题目大意:顺次给出m个置换,重复使用这m个置换对初始序列进行操作.问k次置换后的序列.m<=10, k<2^31. 首先将这m个 ...

  9. 浙大PAT考试1077~1080(2014上机复试题目)

    题目地址:点击打开链接 还是太弱. . 英文太差.,, 预计要等待被虐了.. 1077 找最长的公共后缀,暴力就能够写: #include<iostream> #include<cs ...

  10. 关于Docker&kubernetes的一些问题

    本文是我自己在学习docker以及kubernetes的过程中遇到的一些问题,以及同事在听过培训之后一些问题,事后我自己去网上找些资料以及问一些资深大牛,我在此做一个归纳总结,将这些问题的解答做一个分 ...