How to automatically generate getters and setters in Android Studio

在Android Studio中是否有一个快捷方式来自动生成给定类中的getter和setter?


Using Alt+ Insert in the editor, you may easily generate getter and setter methods for any fields of your class. This has the same effect as using the Menu Bar -> Code -> Generate...

and then using shift or control button, select all the variables you need to add getters and setters


In OSX, ⌘+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

链接地址: http://www.djcxy.com/p/23680.html

上一篇: Realm模型实际上是否需要getter和setter?

下一篇: 如何在Android Studio中自动生成getter和setter