The final local variable cannot be assigned, since it is defined in an enclosing type
来源:互联网 发布:fgo淘宝石头号注意事项 编辑:程序博客网 时间:2024/06/10 04:27
Android项目中遇到的问题,想弹出一个自定义dialog,dialog里有一个下拉列表spinner,当点击完item时,返回被选择的item。代码如下,
//添加事件Spinner事件监听 spinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { keyFile=list.get(arg2); } public void onNothingSelected(AdapterView<?> arg0) { } });
此时会报错The final local variable keyFile cannot be assigned, since it is defined in an enclosing type
解决办法:将本地变量改为局部或全局变量,即将本地变量keyFile定义在函数体外,即可解决。
感谢这里,英文好的话,原版解释在这。等有时间做详细翻译。
0 0
- The final local variable xxx cannot be assigned, since it is defined in an enclosing type
- The final local variable xxx cannot be assigned, since it is defined in an enclosing type
- The final local variable xxx cannot be assigned, since it is defined in an enclosing type“
- The final local variable xxx cannot be assigned, since it is defined in an enclosing type“,
- The final local variable xxx cannot be assigned, since it is defined in an enclosing type
- The final local variable xxx cannot be assigned, since it is defined in an enclosing type
- The final local variable cannot be assigned, since it is defined in an enclosing type
- The final local variable cannot be assigned, since it is defined in an enclosing type的解决办法(把变量从局部编程)
- 解决问题:Cannot refer to the non-final local variable user defined in an enclosing scope
- 16-07-31 Cannot refer to the non-final local variable homePageInfo defined in an enclosing scope
- - No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing in
- The type org.springframework.orm.hibernate3.support.HibernateDaoSupport cannot be resolved. It is in
- Cannot refer to a non-final variable i inside an inner class defined in a differ
- Cannot refer to a non-final variable inside an inner class defined in a different method
- The nested type DBUtil cannot hide an enclosing type
- OUI-10022:The target area /oracle/oraInventory cannot be used because it is in an invalid state.
- Cannot refer to a non-final variable anim inside an inner class defined in a different method
- Cannot refer to a non-final variable music inside an inner class defined in a different method
- hdu4508——湫湫系列故事——减肥记I(背包)
- 深度学习的一些总结(Introduce to Deep learning)
- 106 浏览器判断 正则的妙用
- mongodb 基本语法总结
- JQuery 全选 全不选 反选
- The final local variable cannot be assigned, since it is defined in an enclosing type
- JAVA对象的强,弱,虚引用
- AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0
- C——位运算的学习要点
- 写在今年暑假前
- spring 初始化报错
- 《Single Image Haze Removal Using Dark Channel Prior》一文中图像去雾算法的原理、实现、效果(速度可实时)
- 用正则表达式验证邮箱和手机号
- 折半查找法