Is there a shortcut in Android Studio for automatically generating the getters and setters in a given class?
You can use AndroidAccessors
Plugin of Android Studio
to generate getter and setter without m as prefix to methods
Ex: mId;
Will generate getId()
and setId()
instead of getmId()
and setmId()
Another funny way
Type the parameter name anywhere in the object after definition, you will see setter and getter, Just select and click enter :)
I tried with Android Studio 2.3
Right click on Editor
then Select Source -> Generate Getters and Setters
or press Alt
+ Shift
+ S
for macOS, ⌘+N by default.
Right-click and choose "Generate..." to see current mapping. You can select multiple fields for which to generate getters/setters with one step.
See http://www.jetbrains.com/idea/webhelp/generating-getters-and-setters.html
Android Studio & OSx :
Press cmd+n > Generate > Getter and Setter
Android Studio & Windows :
Press Alt + Insert > Generate > Getter and Setter
You can generate getter and setter by following steps:
That's it. Happy coding!!