Suppose we have some statement for comments which will be repeat many times. Can We use string resources for code comment in android?
Asked
Active
Viewed 241 times
1
-
Why would you want to do that? – Lie Ryan Oct 19 '18 at 11:08
-
I have 3 files where i have to write 3 statements as comment i do not want to write same lines again and again so i thought there may be a solution for it via string resources. – DeveloperByChoice Oct 19 '18 at 11:16
2 Answers
2
No. Comments are ignored by the compiler and runtime engine, therefore there would be no point in referring to a String resource. If you are looking to create the same comment over and over in the source code, recording a macro in Android Studio will do the job better:
Edit -> Macros -> Start Recording Macro
Type out your comment
Edit -> Macros -> Stop Recording Macro
Give your macro a name. Then to use your macro again:
Edit -> Macros -> Play saved macro...
You can also map your macro to a key combination via:
File -> Settings -> Keymap -> Macros

Michael Dodd
- 10,102
- 12
- 51
- 64
-
Thanks @Michael for a quick response let me try your suggestion. – DeveloperByChoice Oct 19 '18 at 11:22
1
Can We use string resources for code comment in android?
No You can't
Comments are just ignored by compiler and never get executed.

V-rund Puro-hit
- 5,518
- 9
- 31
- 50