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

相关文章
|
11月前
Unknown custom element: <add-employee> - did you register the component correctly? For red cursive c
原因: 1.组件名没写对(导入和注册不对应) 2.components少写了个s 3.组件命名最好是驼峰命名 4.导入时语法错误 5.代码中有两个components,后一个的值把前一个覆盖了 6.组件直接循环套用了
error : Class declarations lacks Q_OBJECT macro
error : Class declarations lacks Q_OBJECT macro
|
11月前
|
数据库 OceanBase
RuntimeError: 'PluginContext' object has no attribute 'set_variable'
RuntimeError: 'PluginContext' object has no attribute 'set_variable'
93 2
|
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
242 0
the code place where the binding is converted to final value displayed in u
the code place where the binding is converted to final value displayed in u
107 0
the code place where the binding is converted to final value displayed in u
|
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.
410 0
No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px '.SF NS Text'} No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing instance of type SmsUtils (e.g. x.new A() where x is an instance of SmsUtils). 今天在写一个短信发送的工具类时使用到了内部类,在实例化内部类时遇到此错误。
1430 0