background
It’s been a while since Android studio was used to develop Android. Occasionally, as has a yellow highlight on some private variables field can be converted to a local variable
. I still don’t want to see this yellow highlight for some obsessive-compulsive disorder. Baidu did not find any useful information, or Google search to find some answers.
analysis
The complete description of field can be converted to a local variable
is (hand play only): field can be converted to a local variable
:
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.
This means that it is detected that this variable can be replaced by a local variable. It is recommended to delete it and write it as a local variable.
Solution
Delete the sentence private XXX;
and declare and instantiate it directly where it is used.
In Android studio for Mac
, you can use the shortcut key Alt + enter
to quickly convert local variables.
PS: you still need better English. In fact, you can understand it by reading the instructions. You don’t need to search in this way.
Read More:
- Android notex Q9: pop up settings can be touched
- Error: your local changes to the following files would be rewritten by merge solution
- Local can link to the server database, upload jar package to the server will report an error
- error: Your local changes to the following files would be overwritten by merge
- Android Studio Series: after Android studio is opened, the project window will not be displayed.
- Use xx [‘xx ‘] = XX to set field value or does not support field: XXX
- Property or field ‘Title‘ cannot be found on object of type
- Hzero – if the local swagger fails to register, the connection timeout or gateway error will be displayed
- Git bash display error can not be used, how to solve
- How to Fix Warning: Statement lambda can be replaced with expression lambda
- The local network card cannot be obtained by opening Wireshark
- Solution to Apple Wireless Mouse, keyboard or touchpad can not be recognized by MAC
- error: a label can only be part of a statement and a declaration is not a statement (How to Fix)
- Local workspace file (‘angular.json’) could not be found.
- Error running app:Instant Run requires Tools | Android Enable ADB integration‘ to be enabled.
- Failed to execute tools\ android.bat : minutes! The same thing on the Internet, can’t it be solved? Look at this one!
- Android Studio | Failed to find target with hash string ‘android-26’ in: D:\Android\sdk
- Android studio introduces code error, but it can run normally
- Android studio NDK setting is gray and cannot be solved
- Macfee can not be upgraded, the prompt returns an error