Android:Field can be converted to a local varible.的解决办法
作者:他叫自己MR张 时间:2022-01-23 16:53:14
Android:Field can be converted to a local varible.的解决办法
前言:
使用 Android Studio 开发 Android 有一段时间了,偶尔会碰到 AS 在一些私有变量上有黄色高亮提示Field can be converted to a local varible,有些强迫症的我还是不希望看到这个黄色的高亮。百度没查到什么有用的信息,还是用谷歌搜到了一些解答。
解析
Field can be converted to a local varible 的完整说明是(纯手打):
This inspection searches for redundant class fields that can be replaced with
local variables,if all local usages of a field are preceded by assignments to
that field,the field can be removed and its usages replaced with local variables.
意思是检测到这个变量可以使用局部变量替换,建议删除并写成局部变量。
解决方案
删除private XXX XXX; 这句,并在使用的地方直接声明和实例化。
在 Android Studio for Mac 里可以直接使用快捷键 alt + enter 来快速转换成局部变量。
PS:还是需要英语好点啊,实际上看说明就能明白了,就不用这样通过搜索才明白。
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
来源:http://blog.csdn.net/ys743276112/article/details/50517524
标签:Android,Field
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
简单谈谈JVM、JRE和JDK的区别与联系
2023-04-20 17:14:51
![](https://img.aspxhome.com/file/2023/3/83063_0s.gif)
C++string中的insert()插入函数详解
2023-11-02 14:05:51
![](https://img.aspxhome.com/file/2023/6/105166_0s.png)
浅析java中Integer传参方式的问题
2023-10-27 03:35:43
Java设计模式之建造者模式
2023-09-03 14:40:37
SpringBoot2.6.x升级后循环依赖及Swagger无法使用问题
2021-12-02 09:49:43
![](https://img.aspxhome.com/file/2023/1/88151_0s.png)
SpringBoot超详细讲解@Value注解
2022-03-06 12:05:36
Unity Shader实现裁切效果
2023-03-05 07:54:24
![](https://img.aspxhome.com/file/2023/3/94643_0s.jpg)
详解java IO流之缓冲流的使用
2023-08-08 18:33:16
Java的JDBC中Statement与CallableStatement对象实例
2022-11-14 17:22:08
Java设计模式之备忘录模式实现对象状态的保存和恢复
2023-08-28 15:22:27
![](https://img.aspxhome.com/file/2023/9/58439_0s.png)
C#编程和Visual Studio使用技巧(上)
2021-10-01 00:54:27
![](https://img.aspxhome.com/file/2023/8/104248_0s.jpg)
java实现图片上传至本地实例详解
2023-06-09 03:49:18
![](https://img.aspxhome.com/file/2023/7/91107_0s.png)
Android双击返回键退出程序的实现方法
2022-06-01 01:28:28
使用C# Winform应用程序获取网页源文件的解决方法
2023-02-01 10:56:28
java 多态性详解及简单实例
2021-10-06 23:29:50
Java基于IO流读取文件的方法
2023-08-11 16:23:57
C# Winform使用扩展方法实现自定义富文本框(RichTextBox)字体颜色
2021-06-23 15:05:50
Android中使用CircleImageView和Cardview制作圆形头像的方法
2022-04-19 05:41:35
![](https://img.aspxhome.com/file/2023/2/92582_0s.gif)
MyBatis传入数组集合类并使用foreach遍历
2022-04-19 02:25:00
Java 动态数组的实现示例
2022-02-27 07:05:25
![](https://img.aspxhome.com/file/2023/6/63636_0s.gif)