Cannot refer to a non-final variable anim inside an inner class defined in a different method

简介: AnimationDrawable anim=(AnimationDrawable)imageView.getBackground();                 play.setOnClickListener(new OnClickListener(){           ...

AnimationDrawable anim=(AnimationDrawable)imageView.getBackground();
       
        play.setOnClickListener(new OnClickListener(){
          @Override
    public void onClick(View v) {
    anim.start(); 
    }}
          );

 

 

——>定义anim为final变量:final AnimationDrawable anim

相关文章
Unknown custom element: <add-employee> - did you register the component correctly? For red cursive c
原因: 1.组件名没写对(导入和注册不对应) 2.components少写了个s 3.组件命名最好是驼峰命名 4.导入时语法错误 5.代码中有两个components,后一个的值把前一个覆盖了 6.组件直接循环套用了
101 0
VS2005 error C2864 only static const integral data members can be initialized within a class
VS2005 error C2864 only static const integral data members can be initialized within a class
|
数据库 OceanBase
RuntimeError: 'PluginContext' object has no attribute 'set_variable'
RuntimeError: 'PluginContext' object has no attribute 'set_variable'
120 2
|
JSON 数据格式
成功解决 global init errTypeError:Right-hand side of 'instanceof' is not callable
成功解决 global init errTypeError:Right-hand side of 'instanceof' is not callable
|
Java 程序员 编译器
Variable used in lambda expression should be final or effectively final
Variable used in lambda expression should be final or effectively final
Variable used in lambda expression should be final or effectively final
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
327 0
|
PyTorch 算法框架/工具
Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3.
Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3.
447 0