简体   繁体   English

如何在Android Studio的Alt-Insert getter / setter中删除要设置的前缀(例如“ m”)?

[英]How set prefix (e.g. “m”) to remove in Android Studio's Alt-Insert getter/setter?

I make most of my member variables start with the letter "m", for example mId or mIsSomething . 我将大多数成员变量以字母“ m”开头,例如mIdmIsSomething When I use the keyboard shortcut to add getters/setters, I end up with: 当我使用键盘快捷键添加getter / setter时,最终得到:

public void setmId() {}

but I want: 但我想要:

public void getId() {}

How do I set a prefix for it to remove when creating the getter/setter? 创建getter / setter时如何设置要删除的前缀?

I found the solution: 我找到了解决方案:

Go to File -> Other Settings -> Default Settings 转到File -> Other Settings -> Default Settings

In the search box, type "prefix". 在搜索框中,键入“前缀”。

On the right, select the tab "Code Generation". 在右侧,选择选项卡“代码生成”。

In the "prefix" box, type m (or whatever your prefix is) 在“前缀”框中,键入m (或任何前缀)

  1. Open Default Settings ( File -> Other Settings -> Default Settings ) 打开默认设置( File -> Other Settings -> Default Settings
  2. Go to Editor -> Java -> Code Generation 转到Editor -> Java -> Code Generation
  3. Select Prefer longer names 选择Prefer longer names
  4. Enter m in Field as prefix 在字段中输入m作为前缀

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Android的uiautomator中使用UiObject#setText设置非拉丁字母(例如umlaut) - How to use UiObject#setText to set non-Latin alphabets (e.g. umlaut) in Android's uiautomator 将线框项目(例如 Mockplus)导出到 Android Studio 的方法? - Ways to export Wireframe project (e.g. Mockplus) to Android Studio? Android Studio 无法识别 setter 和 getter - Android Studio not recognizing setter and getter Android Studio:如何列出行数大于N(例如N = 400)的文件 - Android Studio: How to list files whose line count is bigger than N, e.g. N=400 如何禁用Android的特定标签的内部日志记录(例如AbsListView,GestureDetector,endeffect) - How can I disable Android's internal logging for specific tags (e.g. AbsListView, GestureDetector, endeffect) 将 Android Toast 持续时间设置为非常长(例如,1 分钟) - Set Android Toast duration to be really long (e.g., 1 minute) 属性值中“ android:”前缀的含义(例如“ android:imageButtonStyle”) - Meaning of 'android:' prefix within attribute value (e.g. “android:imageButtonStyle”) 如何访问Android资源,例如libgdx中的尺寸? - How to access Android resources e.g. dimensions in libgdx? 如何在Android中精确绘制(例如线条)? - How to draw with precision (e.g. a line) in Android? 如何在Android中的10行列表视图中添加例如5个元素? - How to add e.g. 5 elements to a 10 rows listview in android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM