简体   繁体   中英

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 . When I use the keyboard shortcut to add getters/setters, I end up with:

public void setmId() {}

but I want:

public void getId() {}

How do I set a prefix for it to remove when creating the getter/setter?

I found the solution:

Go to 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)

  1. Open Default Settings ( File -> Other Settings -> Default Settings )
  2. Go to Editor -> Java -> Code Generation
  3. Select Prefer longer names
  4. Enter m in Field as prefix

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM