coutier eric
coutier eric

Reputation: 1019

Android studio : leave my one-line methods as i've typed them when reformating code

Is there an option in android studio to leave one-line method when reformatting code ? For example, for a simple getter, i prefer this style of coding:

public int getPosition() {return mPosition;}

But, when i reformat the code, this method is changed like this:

public int getPosition() {
    return mPosition;
 }

Upvotes: 11

Views: 2878

Answers (1)

coutier eric
coutier eric

Reputation: 1019

Finally, I've found the solution.

  1. Go to File > Settings > Editor > Code Style > Java
  2. Click the Wrapping and Braces tab
  3. Find the Keep when reformatting section
  4. Turn on the Simple methods in one line checkbox

And it just go fine!

Upvotes: 19

Related Questions