如何在 Android Studio 中自动生成 getter 和 setter
问题描述:
Android Studio 中是否有自动生成给定类中的 getter 和 setter 的快捷方式?
Is there a shortcut in Android Studio for automatically generating the getters and setters in a given class?
答
Using Alt+ Insert for Windows or Command+ N for Mac 在编辑器中,您可以轻松地为类的任何字段生成 getter 和 setter 方法.这与使用菜单栏的效果相同 -> Code -> Generate...
Using Alt+ Insert for Windows or Command+ N for Mac 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...
然后使用 shift 或 control 按钮,选择需要添加 getter 和 setter 的所有变量
and then using shift or control button, select all the variables you need to add getters and setters